var gridster; jQuery(function(){ if(typeof pp_top_bottom_padding==='undefined'||pp_top_bottom_padding===null){pp_top_bottom_padding=10;} if(typeof pp_left_right_padding==='undefined'||pp_left_right_padding===null){pp_left_right_padding=10;} if(typeof pp_grid_width==='undefined'||pp_grid_width===null){pp_grid_width=90;} if(typeof pp_grid_height==='undefined'||pp_grid_height===null){pp_grid_height=35;} gridster=jQuery(".gridster ul").gridster({ widget_margins: [pp_top_bottom_padding, pp_left_right_padding], widget_base_dimensions: [pp_grid_width, pp_grid_height], helper: 'clone', }).data('gridster'); if(gridster){gridster.disable();} gridster_mobile=jQuery(".gridster-mobile ul").gridster({ widget_margins: [pp_top_bottom_padding, pp_left_right_padding], widget_base_dimensions: [pp_grid_width, pp_grid_height], helper: 'clone', }).data('gridster'); if(gridster_mobile){gridster_mobile.disable();} jQuery('.upcp-gridster-loading').removeClass('upcp-Hide-Item'); }); ;(function(root, factory){ if(typeof define==='function'&&define.amd){ define('gridster-coords', ['jquery'], factory); }else{ root.GridsterCoords=factory(root.$||root.jQuery); }}(this, function($){ function Coords(obj){ if(obj[0]&&$.isPlainObject(obj[0])){ this.data=obj[0]; }else{ this.el=obj; } this.isCoords=true; this.coords={}; this.init(); return this; } var fn=Coords.prototype; fn.init=function(){ this.set(); this.original_coords=this.get(); }; fn.set=function(update, not_update_offsets){ var el=this.el; if(el&&!update){ this.data=el.offset(); this.data.width=el.width(); this.data.height=el.height(); } if(el&&update&&!not_update_offsets){ var offset=el.offset(); this.data.top=offset.top; this.data.left=offset.left; } var d=this.data; typeof d.left==='undefined'&&(d.left=d.x1); typeof d.top==='undefined'&&(d.top=d.y1); this.coords.x1=d.left; this.coords.y1=d.top; this.coords.x2=d.left + d.width; this.coords.y2=d.top + d.height; this.coords.cx=d.left + (d.width / 2); this.coords.cy=d.top + (d.height / 2); this.coords.width=d.width; this.coords.height=d.height; this.coords.el=el||false ; return this; }; fn.update=function(data){ if(!data&&!this.el){ return this; } if(data){ var new_data=$.extend({}, this.data, data); this.data=new_data; return this.set(true, true); } this.set(true); return this; }; fn.get=function(){ return this.coords; }; fn.destroy=function(){ this.el.removeData('coords'); delete this.el; }; $.fn.coords=function(){ if(this.data('coords')){ return this.data('coords'); } var ins=new Coords(this, arguments[0]); this.data('coords', ins); return ins; }; return Coords; })); ;(function(root, factory){ if(typeof define==='function'&&define.amd){ define('gridster-collision', ['jquery', 'gridster-coords'], factory); }else{ root.GridsterCollision=factory(root.$||root.jQuery, root.GridsterCoords); }}(this, function($, Coords){ var defaults={ colliders_context: document.body, overlapping_region: 'C' }; function Collision(el, colliders, options){ this.options=$.extend(defaults, options); this.$element=el; this.last_colliders=[]; this.last_colliders_coords=[]; this.set_colliders(colliders); this.init(); } Collision.defaults=defaults; var fn=Collision.prototype; fn.init=function(){ this.find_collisions(); }; fn.overlaps=function(a, b){ var x=false; var y=false; if((b.x1 >=a.x1&&b.x1 <=a.x2) || (b.x2 >=a.x1&&b.x2 <=a.x2) || (a.x1 >=b.x1&&a.x2 <=b.x2) ){ x=true; } if((b.y1 >=a.y1&&b.y1 <=a.y2) || (b.y2 >=a.y1&&b.y2 <=a.y2) || (a.y1 >=b.y1&&a.y2 <=b.y2) ){ y=true; } return (x&&y); }; fn.detect_overlapping_region=function(a, b){ var regionX=''; var regionY=''; if(a.y1 > b.cy&&a.y1 < b.y2){ regionX='N'; } if(a.y2 > b.y1&&a.y2 < b.cy){ regionX='S'; } if(a.x1 > b.cx&&a.x1 < b.x2){ regionY='W'; } if(a.x2 > b.x1&&a.x2 < b.cx){ regionY='E'; } return (regionX + regionY)||'C'; }; fn.calculate_overlapped_area_coords=function(a, b){ var x1=Math.max(a.x1, b.x1); var y1=Math.max(a.y1, b.y1); var x2=Math.min(a.x2, b.x2); var y2=Math.min(a.y2, b.y2); return $({ left: x1, top: y1, width:(x2 - x1), height: (y2 - y1) }).coords().get(); }; fn.calculate_overlapped_area=function(coords){ return (coords.width * coords.height); }; fn.manage_colliders_start_stop=function(new_colliders_coords, start_callback, stop_callback){ var last=this.last_colliders_coords; for (var i=0, il=last.length; i < il; i++){ if($.inArray(last[i], new_colliders_coords)===-1){ start_callback.call(this, last[i]); }} for (var j=0, jl=new_colliders_coords.length; j < jl; j++){ if($.inArray(new_colliders_coords[j], last)===-1){ stop_callback.call(this, new_colliders_coords[j]); }} }; fn.find_collisions=function(player_data_coords){ var self=this; var overlapping_region=this.options.overlapping_region; var colliders_coords=[]; var colliders_data=[]; var $colliders=(this.colliders||this.$colliders); var count=$colliders.length; var player_coords=self.$element.coords() .update(player_data_coords||false).get(); while(count--){ var $collider=self.$colliders ? $($colliders[count]):$colliders[count]; var $collider_coords_ins=($collider.isCoords) ? $collider:$collider.coords(); var collider_coords=$collider_coords_ins.get(); var overlaps=self.overlaps(player_coords, collider_coords); if(!overlaps){ continue; } var region=self.detect_overlapping_region(player_coords, collider_coords); if(region===overlapping_region||overlapping_region==='all'){ var area_coords=self.calculate_overlapped_area_coords(player_coords, collider_coords); var area=self.calculate_overlapped_area(area_coords); var collider_data={ area: area, area_coords:area_coords, region: region, coords: collider_coords, player_coords: player_coords, el: $collider }; if(self.options.on_overlap){ self.options.on_overlap.call(this, collider_data); } colliders_coords.push($collider_coords_ins); colliders_data.push(collider_data); }} if(self.options.on_overlap_stop||self.options.on_overlap_start){ this.manage_colliders_start_stop(colliders_coords, self.options.on_overlap_start, self.options.on_overlap_stop); } this.last_colliders_coords=colliders_coords; return colliders_data; }; fn.get_closest_colliders=function(player_data_coords){ var colliders=this.find_collisions(player_data_coords); colliders.sort(function(a, b){ if(a.region==='C'&&b.region==='C'){ if(a.coords.y1 < b.coords.y1||a.coords.x1 < b.coords.x1){ return - 1; }else{ return 1; }} if(a.area < b.area){ return 1; } return 1; }); return colliders; }; fn.set_colliders=function(colliders){ if(typeof colliders==='string'||colliders instanceof $){ this.$colliders=$(colliders, this.options.colliders_context).not(this.$element); }else{ this.colliders=$(colliders); }}; $.fn.collision=function(collider, options){ return new Collision(this, collider, options); }; return Collision; })); ;(function(window, undefined){ window.delay=function(func, wait){ var args=Array.prototype.slice.call(arguments, 2); return setTimeout(function(){ return func.apply(null, args); }, wait); }; window.debounce=function(func, wait, immediate){ var timeout; return function(){ var context=this, args=arguments; var later=function(){ timeout=null; if(!immediate) func.apply(context, args); }; if(immediate&&!timeout) func.apply(context, args); clearTimeout(timeout); timeout=setTimeout(later, wait); };}; window.throttle=function(func, wait){ var context, args, timeout, throttling, more, result; var whenDone=debounce( function(){ more=throttling=false; }, wait); return function(){ context=this; args=arguments; var later=function(){ timeout=null; if(more) func.apply(context, args); whenDone(); }; if(!timeout) timeout=setTimeout(later, wait); if(throttling){ more=true; }else{ result=func.apply(context, args); } whenDone(); throttling=true; return result; };}; })(window); ;(function(root, factory){ if(typeof define==='function'&&define.amd){ define('gridster-draggable', ['jquery'], factory); }else{ root.GridsterDraggable=factory(root.$||root.jQuery); }}(this, function($){ var defaults={ items: 'li', distance: 1, limit: true, offset_left: 0, autoscroll: true, ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'], handle: null, container_width: 0, move_element: true, helper: false, remove_helper: true }; var $window=$(window); var dir_map={ x:'left', y:'top' }; var isTouch = !!('ontouchstart' in window); var capitalize=function(str){ return str.charAt(0).toUpperCase() + str.slice(1); }; var idCounter=0; var uniqId=function(){ return ++idCounter + ''; } function Draggable(el, options){ this.options=$.extend({}, defaults, options); this.$document=$(document); this.$container=$(el); this.$dragitems=$(this.options.items, this.$container); this.is_dragging=false; this.player_min_left=0 + this.options.offset_left; this.id=uniqId(); this.ns='.gridster-draggable-' + this.id; this.init(); } Draggable.defaults=defaults; var fn=Draggable.prototype; fn.init=function(){ var pos=this.$container.css('position'); this.calculate_dimensions(); this.$container.css('position', pos==='static' ? 'relative':pos); this.disabled=false; this.events(); $(window).bind(this.nsEvent('resize'), throttle($.proxy(this.calculate_dimensions, this), 200)); }; fn.nsEvent=function(ev){ return (ev||'') + this.ns; }; fn.events=function(){ this.pointer_events={ start: this.nsEvent('touchstart') + ' ' + this.nsEvent('mousedown'), move: this.nsEvent('touchmove') + ' ' + this.nsEvent('mousemove'), end: this.nsEvent('touchend') + ' ' + this.nsEvent('mouseup'), }; this.$container.on(this.nsEvent('selectstart'), $.proxy(this.on_select_start, this)); this.$container.on(this.pointer_events.start, this.options.items, $.proxy(this.drag_handler, this)); this.$document.on(this.pointer_events.end, $.proxy(function(e){ this.is_dragging=false; if(this.disabled){ return; } this.$document.off(this.pointer_events.move); if(this.drag_start){ this.on_dragstop(e); }}, this)); }; fn.get_actual_pos=function($el){ var pos=$el.position(); return pos; }; fn.get_mouse_pos=function(e){ if(e.originalEvent&&e.originalEvent.touches){ var oe=e.originalEvent; e=oe.touches.length ? oe.touches[0]:oe.changedTouches[0]; } return { left: e.clientX, top: e.clientY };}; fn.get_offset=function(e){ e.preventDefault(); var mouse_actual_pos=this.get_mouse_pos(e); var diff_x=Math.round(mouse_actual_pos.left - this.mouse_init_pos.left); var diff_y=Math.round(mouse_actual_pos.top - this.mouse_init_pos.top); var left=Math.round(this.el_init_offset.left + diff_x - this.baseX + $(window).scrollLeft() - this.win_offset_x); var top=Math.round(this.el_init_offset.top + diff_y - this.baseY + $(window).scrollTop() - this.win_offset_y); if(this.options.limit){ if(left > this.player_max_left){ left=this.player_max_left; }else if(left < this.player_min_left){ left=this.player_min_left; }} return { position: { left: left, top: top }, pointer: { left: mouse_actual_pos.left, top: mouse_actual_pos.top, diff_left: diff_x + ($(window).scrollLeft() - this.win_offset_x), diff_top: diff_y + ($(window).scrollTop() - this.win_offset_y) }};}; fn.get_drag_data=function(e){ var offset=this.get_offset(e); offset.$player=this.$player; offset.$helper=this.helper ? this.$helper:this.$player; return offset; }; fn.set_limits=function(container_width){ container_width||(container_width=this.$container.width()); this.player_max_left=(container_width - this.player_width + - this.options.offset_left); this.options.container_width=container_width; return this; }; fn.scroll_in=function(axis, data){ var dir_prop=dir_map[axis]; var area_size=50; var scroll_inc=30; var is_x=axis==='x'; var window_size=is_x ? this.window_width:this.window_height; var doc_size=is_x ? $(document).width():$(document).height(); var player_size=is_x ? this.$player.width():this.$player.height(); var next_scroll; var scroll_offset=$window['scroll' + capitalize(dir_prop)](); var min_window_pos=scroll_offset; var max_window_pos=min_window_pos + window_size; var mouse_next_zone=max_window_pos - area_size; var mouse_prev_zone=min_window_pos + area_size; var abs_mouse_pos=min_window_pos + data.pointer[dir_prop]; var max_player_pos=(doc_size - window_size + player_size); if(abs_mouse_pos >=mouse_next_zone){ next_scroll=scroll_offset + scroll_inc; if(next_scroll < max_player_pos){ $window['scroll' + capitalize(dir_prop)](next_scroll); this['scroll_offset_' + axis] +=scroll_inc; }} if(abs_mouse_pos <=mouse_prev_zone){ next_scroll=scroll_offset - scroll_inc; if(next_scroll > 0){ $window['scroll' + capitalize(dir_prop)](next_scroll); this['scroll_offset_' + axis] -=scroll_inc; }} return this; }; fn.manage_scroll=function(data){ this.scroll_in('x', data); this.scroll_in('y', data); }; fn.calculate_dimensions=function(e){ this.window_height=$window.height(); this.window_width=$window.width(); }; fn.drag_handler=function(e){ var node=e.target.nodeName; if(this.disabled||e.which!==1&&!isTouch){ return; } if(this.ignore_drag(e)){ return; } var self=this; var first=true; this.$player=$(e.currentTarget); this.el_init_pos=this.get_actual_pos(this.$player); this.mouse_init_pos=this.get_mouse_pos(e); this.offsetY=this.mouse_init_pos.top - this.el_init_pos.top; this.$document.on(this.pointer_events.move, function(mme){ var mouse_actual_pos=self.get_mouse_pos(mme); var diff_x=Math.abs(mouse_actual_pos.left - self.mouse_init_pos.left); var diff_y=Math.abs(mouse_actual_pos.top - self.mouse_init_pos.top); if(!(diff_x > self.options.distance || diff_y > self.options.distance) ){ return false; } if(first){ first=false; self.on_dragstart.call(self, mme); return false; } if(self.is_dragging===true){ self.on_dragmove.call(self, mme); } return false; }); if(!isTouch){ return false; }}; fn.on_dragstart=function(e){ e.preventDefault(); if(this.is_dragging){ return this; } this.drag_start=this.is_dragging=true; var offset=this.$container.offset(); this.baseX=Math.round(offset.left); this.baseY=Math.round(offset.top); this.initial_container_width=this.options.container_width||this.$container.width(); if(this.options.helper==='clone'){ this.$helper=this.$player.clone() .appendTo(this.$container).addClass('helper'); this.helper=true; }else{ this.helper=false; } this.win_offset_y=$(window).scrollTop(); this.win_offset_x=$(window).scrollLeft(); this.scroll_offset_y=0; this.scroll_offset_x=0; this.el_init_offset=this.$player.offset(); this.player_width=this.$player.width(); this.player_height=this.$player.height(); this.set_limits(this.options.container_width); if(this.options.start){ this.options.start.call(this.$player, e, this.get_drag_data(e)); } return false; }; fn.on_dragmove=function(e){ var data=this.get_drag_data(e); this.options.autoscroll&&this.manage_scroll(data); if(this.options.move_element){ (this.helper ? this.$helper:this.$player).css({ 'position': 'absolute', 'left':data.position.left, 'top':data.position.top }); } var last_position=this.last_position||data.position; data.prev_position=last_position; if(this.options.drag){ this.options.drag.call(this.$player, e, data); } this.last_position=data.position; return false; }; fn.on_dragstop=function(e){ var data=this.get_drag_data(e); this.drag_start=false; if(this.options.stop){ this.options.stop.call(this.$player, e, data); } if(this.helper&&this.options.remove_helper){ this.$helper.remove(); } return false; }; fn.on_select_start=function(e){ if(this.disabled){ return; } if(this.ignore_drag(e)){ return; } return false; }; fn.enable=function(){ this.disabled=false; }; fn.disable=function(){ this.disabled=true; }; fn.destroy=function(){ this.disable(); this.$container.off(this.ns); this.$document.off(this.ns); $(window).off(this.ns); $.removeData(this.$container, 'drag'); }; fn.ignore_drag=function(event){ if(this.options.handle){ return !$(event.target).is(this.options.handle); } if($.isFunction(this.options.ignore_dragging)){ return this.options.ignore_dragging(event); } return $(event.target).is(this.options.ignore_dragging.join(', ')); }; $.fn.drag=function(options){ return new Draggable(this, options); }; return Draggable; })); ;(function(root, factory){ if(typeof define==='function'&&define.amd){ define(['jquery', 'gridster-draggable', 'gridster-collision'], factory); }else{ root.Gridster=factory(root.$||root.jQuery, root.GridsterDraggable, root.GridsterCollision); }}(this, function($, Draggable, Collision){ var defaults={ namespace: '', widget_selector: 'li', widget_margins: [10, 10], widget_base_dimensions: [400, 225], extra_rows: 0, extra_cols: 0, min_cols: 1, max_cols: Infinity, min_rows: 15, max_size_x: false, autogrow_cols: false, autogenerate_stylesheet: true, avoid_overlapped_widgets: true, auto_init: true, serialize_params: function($w, wgd){ return { col: wgd.col, row: wgd.row, size_x: wgd.size_x, size_y: wgd.size_y };}, collision: {}, draggable: { items: '.gs-w', distance: 4, ignore_dragging: Draggable.defaults.ignore_dragging.slice(0) }, resize: { enabled: false, axes: ['both'], handle_append_to: '', handle_class: 'gs-resize-handle', max_size: [Infinity, Infinity], min_size: [1, 1] }}; function Gridster(el, options){ this.options=$.extend(true, {}, defaults, options); this.$el=$(el); this.$wrapper=this.$el.parent(); this.$widgets=this.$el.children(this.options.widget_selector).addClass('gs-w'); this.widgets=[]; this.$changed=$([]); this.wrapper_width=this.$wrapper.width(); this.min_widget_width=(this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0]; this.min_widget_height=(this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1]; this.generated_stylesheets=[]; this.$style_tags=$([]); this.options.auto_init&&this.init(); } Gridster.defaults=defaults; Gridster.generated_stylesheets=[]; Gridster.sort_by_row_asc=function(widgets){ widgets=widgets.sort(function(a, b){ if(!a.row){ a=$(a).coords().grid; b=$(b).coords().grid; } if(a.row > b.row){ return 1; } return -1; }); return widgets; }; Gridster.sort_by_row_and_col_asc=function(widgets){ widgets=widgets.sort(function(a, b){ if(a.row > b.row||a.row===b.row&&a.col > b.col){ return 1; } return -1; }); return widgets; }; Gridster.sort_by_col_asc=function(widgets){ widgets=widgets.sort(function(a, b){ if(a.col > b.col){ return 1; } return -1; }); return widgets; }; Gridster.sort_by_row_desc=function(widgets){ widgets=widgets.sort(function(a, b){ if(a.row + a.size_y < b.row + b.size_y){ return 1; } return -1; }); return widgets; }; var fn=Gridster.prototype; fn.init=function(){ this.options.resize.enabled&&this.setup_resize(); this.generate_grid_and_stylesheet(); this.get_widgets_from_DOM(); this.set_dom_grid_height(); this.set_dom_grid_width(); this.$wrapper.addClass('ready'); this.draggable(); this.options.resize.enabled&&this.resizable(); $(window).bind('resize.gridster', throttle( $.proxy(this.recalculate_faux_grid, this), 200)); }; fn.disable=function(){ this.$wrapper.find('.player-revert').removeClass('player-revert'); this.drag_api.disable(); return this; }; fn.enable=function(){ this.drag_api.enable(); return this; }; fn.disable_resize=function(){ this.$el.addClass('gs-resize-disabled'); this.resize_api.disable(); return this; }; fn.enable_resize=function(){ this.$el.removeClass('gs-resize-disabled'); this.resize_api.enable(); return this; }; fn.add_widget=function(html, size_x, size_y, col, row, max_size, min_size){ var pos; size_x||(size_x=1); size_y||(size_y=1); if(!col & !row){ pos=this.next_position(size_x, size_y); }else{ pos={ col: col, row: row, size_x: size_x, size_y: size_y }; this.empty_cells(col, row, size_x, size_y); } var $w=$(html).attr({ 'data-col': pos.col, 'data-row': pos.row, 'data-sizex':size_x, 'data-sizey':size_y }).addClass('gs-w').appendTo(this.$el).hide(); this.$widgets=this.$widgets.add($w); this.register_widget($w); this.add_faux_rows(pos.size_y); if(max_size){ this.set_widget_max_size($w, max_size); } if(min_size){ this.set_widget_min_size($w, min_size); } this.set_dom_grid_width(); this.set_dom_grid_height(); this.drag_api.set_limits(this.cols * this.min_widget_width); return $w.fadeIn(); }; fn.set_widget_min_size=function($widget, min_size){ $widget=typeof $widget==='number' ? this.$widgets.eq($widget):$widget; if(!$widget.length){ return this; } var wgd=$widget.data('coords').grid; wgd.min_size_x=min_size[0]; wgd.min_size_y=min_size[1]; return this; }; fn.set_widget_max_size=function($widget, max_size){ $widget=typeof $widget==='number' ? this.$widgets.eq($widget):$widget; if(!$widget.length){ return this; } var wgd=$widget.data('coords').grid; wgd.max_size_x=max_size[0]; wgd.max_size_y=max_size[1]; return this; }; fn.add_resize_handle=function($w){ var append_to=this.options.resize.handle_append_to; $(this.resize_handle_tpl).appendTo(append_to ? $(append_to, $w):$w); return this; }; fn.resize_widget=function($widget, size_x, size_y, callback){ var wgd=$widget.coords().grid; var col=wgd.col; var max_cols=this.options.max_cols; var old_size_y=wgd.size_y; var old_col=wgd.col; var new_col=old_col; size_x||(size_x=wgd.size_x); size_y||(size_y=wgd.size_y); if(max_cols!==Infinity){ size_x=Math.min(size_x, max_cols - col + 1); } if(size_y > old_size_y){ this.add_faux_rows(Math.max(size_y - old_size_y, 0)); } var player_rcol=(col + size_x - 1); if(player_rcol > this.cols){ this.add_faux_cols(player_rcol - this.cols); } var new_grid_data={ col: new_col, row: wgd.row, size_x: size_x, size_y: size_y }; this.mutate_widget_in_gridmap($widget, wgd, new_grid_data); this.set_dom_grid_height(); this.set_dom_grid_width(); if(callback){ callback.call(this, new_grid_data.size_x, new_grid_data.size_y); } return $widget; }; fn.mutate_widget_in_gridmap=function($widget, wgd, new_wgd){ var old_size_x=wgd.size_x; var old_size_y=wgd.size_y; var old_cells_occupied=this.get_cells_occupied(wgd); var new_cells_occupied=this.get_cells_occupied(new_wgd); var empty_cols=[]; $.each(old_cells_occupied.cols, function(i, col){ if($.inArray(col, new_cells_occupied.cols)===-1){ empty_cols.push(col); }}); var occupied_cols=[]; $.each(new_cells_occupied.cols, function(i, col){ if($.inArray(col, old_cells_occupied.cols)===-1){ occupied_cols.push(col); }}); var empty_rows=[]; $.each(old_cells_occupied.rows, function(i, row){ if($.inArray(row, new_cells_occupied.rows)===-1){ empty_rows.push(row); }}); var occupied_rows=[]; $.each(new_cells_occupied.rows, function(i, row){ if($.inArray(row, old_cells_occupied.rows)===-1){ occupied_rows.push(row); }}); this.remove_from_gridmap(wgd); if(occupied_cols.length){ var cols_to_empty=[ new_wgd.col, new_wgd.row, new_wgd.size_x, Math.min(old_size_y, new_wgd.size_y), $widget ]; this.empty_cells.apply(this, cols_to_empty); } if(occupied_rows.length){ var rows_to_empty=[new_wgd.col, new_wgd.row, new_wgd.size_x, new_wgd.size_y, $widget]; this.empty_cells.apply(this, rows_to_empty); } wgd.col=new_wgd.col; wgd.row=new_wgd.row; wgd.size_x=new_wgd.size_x; wgd.size_y=new_wgd.size_y; this.add_to_gridmap(new_wgd, $widget); $widget.removeClass('player-revert'); $widget.data('coords').update({ width: (new_wgd.size_x * this.options.widget_base_dimensions[0] + ((new_wgd.size_x - 1) * this.options.widget_margins[0]) * 2), height: (new_wgd.size_y * this.options.widget_base_dimensions[1] + ((new_wgd.size_y - 1) * this.options.widget_margins[1]) * 2) }); $widget.attr({ 'data-col': new_wgd.col, 'data-row': new_wgd.row, 'data-sizex': new_wgd.size_x, 'data-sizey': new_wgd.size_y }); if(empty_cols.length){ var cols_to_remove_holes=[ empty_cols[0], new_wgd.row, empty_cols.length, Math.min(old_size_y, new_wgd.size_y), $widget ]; this.remove_empty_cells.apply(this, cols_to_remove_holes); } if(empty_rows.length){ var rows_to_remove_holes=[ new_wgd.col, new_wgd.row, new_wgd.size_x, new_wgd.size_y, $widget ]; this.remove_empty_cells.apply(this, rows_to_remove_holes); } this.move_widget_up($widget); return this; }; fn.empty_cells=function(col, row, size_x, size_y, $exclude){ var $nexts=this.widgets_below({ col: col, row: row - size_y, size_x: size_x, size_y: size_y }); $nexts.not($exclude).each($.proxy(function(i, w){ var wgd=$(w).coords().grid; if(!(wgd.row <=(row + size_y - 1))){ return; } var diff=(row + size_y) - wgd.row; this.move_widget_down($(w), diff); }, this)); this.set_dom_grid_height(); return this; }; fn.remove_empty_cells=function(col, row, size_x, size_y, exclude){ var $nexts=this.widgets_below({ col: col, row: row, size_x: size_x, size_y: size_y }); $nexts.not(exclude).each($.proxy(function(i, widget){ this.move_widget_up($(widget), size_y); }, this)); this.set_dom_grid_height(); return this; }; fn.next_position=function(size_x, size_y){ size_x||(size_x=1); size_y||(size_y=1); var ga=this.gridmap; var cols_l=ga.length; var valid_pos=[]; var rows_l; for (var c=1; c < cols_l; c++){ rows_l=ga[c].length; for (var r=1; r <=rows_l; r++){ var can_move_to=this.can_move_to({ size_x: size_x, size_y: size_y }, c, r); if(can_move_to){ valid_pos.push({ col: c, row: r, size_y: size_y, size_x: size_x }); }} } if(valid_pos.length){ return Gridster.sort_by_row_and_col_asc(valid_pos)[0]; } return false; }; fn.remove_widget=function(el, silent, callback){ var $el=el instanceof $ ? el:$(el); var wgd=$el.coords().grid; if($.isFunction(silent)){ callback=silent; silent=false; } this.cells_occupied_by_placeholder={}; this.$widgets=this.$widgets.not($el); var $nexts=this.widgets_below($el); this.remove_from_gridmap(wgd); $el.fadeOut($.proxy(function(){ $el.remove(); if(!silent){ $nexts.each($.proxy(function(i, widget){ this.move_widget_up($(widget), wgd.size_y); }, this)); } this.set_dom_grid_height(); if(callback){ callback.call(this, el); }}, this)); return this; }; fn.remove_all_widgets=function(callback){ this.$widgets.each($.proxy(function(i, el){ this.remove_widget(el, true, callback); }, this)); return this; }; fn.serialize=function($widgets){ $widgets||($widgets=this.$widgets); return $widgets.map($.proxy(function(i, widget){ var $w=$(widget); return this.options.serialize_params($w, $w.coords().grid); }, this)).get(); }; fn.serialize_changed=function(){ return this.serialize(this.$changed); }; fn.dom_to_coords=function($widget){ return { 'col': parseInt($widget.attr('data-col'), 10), 'row': parseInt($widget.attr('data-row'), 10), 'size_x': parseInt($widget.attr('data-sizex'), 10)||1, 'size_y': parseInt($widget.attr('data-sizey'), 10)||1, 'max_size_x': parseInt($widget.attr('data-max-sizex'), 10)||false, 'max_size_y': parseInt($widget.attr('data-max-sizey'), 10)||false, 'min_size_x': parseInt($widget.attr('data-min-sizex'), 10)||false, 'min_size_y': parseInt($widget.attr('data-min-sizey'), 10)||false, 'el': $widget };}; fn.register_widget=function($el){ var isDOM=$el instanceof jQuery; var wgd=isDOM ? this.dom_to_coords($el):$el; var posChanged=false; isDOM||($el=wgd.el); var empty_upper_row=this.can_go_widget_up(wgd); if(empty_upper_row){ wgd.row=empty_upper_row; $el.attr('data-row', empty_upper_row); this.$el.trigger('gridster:positionchanged', [wgd]); posChanged=true; } if(this.options.avoid_overlapped_widgets && !this.can_move_to({size_x: wgd.size_x, size_y: wgd.size_y}, wgd.col, wgd.row) ){ $.extend(wgd, this.next_position(wgd.size_x, wgd.size_y)); $el.attr({ 'data-col': wgd.col, 'data-row': wgd.row, 'data-sizex': wgd.size_x, 'data-sizey': wgd.size_y }); posChanged=true; } $el.data('coords', $el.coords()); $el.data('coords').grid=wgd; this.add_to_gridmap(wgd, $el); this.options.resize.enabled&&this.add_resize_handle($el); return posChanged; }; fn.update_widget_position=function(grid_data, value){ this.for_each_cell_occupied(grid_data, function(col, row){ if(!this.gridmap[col]){ return this; } this.gridmap[col][row]=value; }); return this; }; fn.remove_from_gridmap=function(grid_data){ return this.update_widget_position(grid_data, false); }; fn.add_to_gridmap=function(grid_data, value){ this.update_widget_position(grid_data, value||grid_data.el); if(grid_data.el){ var $widgets=this.widgets_below(grid_data.el); $widgets.each($.proxy(function(i, widget){ this.move_widget_up($(widget)); }, this)); }}; fn.draggable=function(){ var self=this; var draggable_options=$.extend(true, {}, this.options.draggable, { offset_left: this.options.widget_margins[0], offset_top: this.options.widget_margins[1], container_width: this.cols * this.min_widget_width, limit: true, start: function(event, ui){ self.$widgets.filter('.player-revert') .removeClass('player-revert'); self.$player=$(this); self.$helper=$(ui.$helper); self.helper = !self.$helper.is(self.$player); self.on_start_drag.call(self, event, ui); self.$el.trigger('gridster:dragstart'); }, stop: function(event, ui){ self.on_stop_drag.call(self, event, ui); self.$el.trigger('gridster:dragstop'); }, drag: throttle(function(event, ui){ self.on_drag.call(self, event, ui); self.$el.trigger('gridster:drag'); }, 60) }); this.drag_api=this.$el.drag(draggable_options); return this; }; fn.resizable=function(){ this.resize_api=this.$el.drag({ items: '.' + this.options.resize.handle_class, offset_left: this.options.widget_margins[0], container_width: this.container_width, move_element: false, resize: true, limit: this.options.autogrow_cols ? false:true, start: $.proxy(this.on_start_resize, this), stop: $.proxy(function(event, ui){ delay($.proxy(function(){ this.on_stop_resize(event, ui); }, this), 120); }, this), drag: throttle($.proxy(this.on_resize, this), 60) }); return this; }; fn.setup_resize=function(){ this.resize_handle_class=this.options.resize.handle_class; var axes=this.options.resize.axes; var handle_tpl=''; this.resize_handle_tpl=$.map(axes, function(type){ return handle_tpl.replace('{type}', type); }).join(''); if($.isArray(this.options.draggable.ignore_dragging)){ this.options.draggable.ignore_dragging.push('.' + this.resize_handle_class); } return this; }; fn.on_start_drag=function(event, ui){ this.$helper.add(this.$player).add(this.$wrapper).addClass('dragging'); this.highest_col=this.get_highest_occupied_cell().col; this.$player.addClass('player'); this.player_grid_data=this.$player.coords().grid; this.placeholder_grid_data=$.extend({}, this.player_grid_data); this.set_dom_grid_height(this.$el.height() + (this.player_grid_data.size_y * this.min_widget_height)); this.set_dom_grid_width(this.cols); var pgd_sizex=this.player_grid_data.size_x; var cols_diff=this.cols - this.highest_col; if(this.options.autogrow_cols&&cols_diff <=pgd_sizex){ this.add_faux_cols(Math.min(pgd_sizex - cols_diff, 1)); } var colliders=this.faux_grid; var coords=this.$player.data('coords').coords; this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data); this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data); this.last_cols=[]; this.last_rows=[]; this.collision_api=this.$helper.collision(colliders, this.options.collision); this.$preview_holder=$('<' + this.$player.get(0).tagName + ' />', { 'class': 'preview-holder', 'data-row': this.$player.attr('data-row'), 'data-col': this.$player.attr('data-col'), css: { width: coords.width, height: coords.height }}).appendTo(this.$el); if(this.options.draggable.start){ this.options.draggable.start.call(this, event, ui); }}; fn.on_drag=function(event, ui){ if(this.$player===null){ return false; } var abs_offset={ left: ui.position.left + this.baseX, top: ui.position.top + this.baseY }; if(this.options.autogrow_cols){ var prcol=this.placeholder_grid_data.col + this.placeholder_grid_data.size_x - 1; if(prcol >=this.cols - 1&&this.options.max_cols >=this.cols + 1){ this.add_faux_cols(1); this.set_dom_grid_width(this.cols + 1); this.drag_api.set_limits(this.container_width); } this.collision_api.set_colliders(this.faux_grid); } this.colliders_data=this.collision_api.get_closest_colliders(abs_offset); this.on_overlapped_column_change(this.on_start_overlapping_column, this.on_stop_overlapping_column); this.on_overlapped_row_change(this.on_start_overlapping_row, this.on_stop_overlapping_row); if(this.helper&&this.$player){ this.$player.css({ 'left': ui.position.left, 'top': ui.position.top }); } if(this.options.draggable.drag){ this.options.draggable.drag.call(this, event, ui); }}; fn.on_stop_drag=function(event, ui){ this.$helper.add(this.$player).add(this.$wrapper) .removeClass('dragging'); ui.position.left=ui.position.left + this.baseX; ui.position.top=ui.position.top + this.baseY; this.colliders_data=this.collision_api.get_closest_colliders(ui.position); this.on_overlapped_column_change(this.on_start_overlapping_column, this.on_stop_overlapping_column ); this.on_overlapped_row_change(this.on_start_overlapping_row, this.on_stop_overlapping_row ); this.$player.addClass('player-revert').removeClass('player') .attr({ 'data-col': this.placeholder_grid_data.col, 'data-row': this.placeholder_grid_data.row }).css({ 'left': '', 'top': '' }); this.$changed=this.$changed.add(this.$player); this.cells_occupied_by_player=this.get_cells_occupied(this.placeholder_grid_data); this.set_cells_player_occupies(this.placeholder_grid_data.col, this.placeholder_grid_data.row); this.$player.coords().grid.row=this.placeholder_grid_data.row; this.$player.coords().grid.col=this.placeholder_grid_data.col; if(this.options.draggable.stop){ this.options.draggable.stop.call(this, event, ui); } this.$preview_holder.remove(); this.$player=null; this.$helper=null; this.placeholder_grid_data={}; this.player_grid_data={}; this.cells_occupied_by_placeholder={}; this.cells_occupied_by_player={}; this.set_dom_grid_height(); this.set_dom_grid_width(); if(this.options.autogrow_cols){ this.drag_api.set_limits(this.cols * this.min_widget_width); }}; fn.on_start_resize=function(event, ui){ this.$resized_widget=ui.$player.closest('.gs-w'); this.resize_coords=this.$resized_widget.coords(); this.resize_wgd=this.resize_coords.grid; this.resize_initial_width=this.resize_coords.coords.width; this.resize_initial_height=this.resize_coords.coords.height; this.resize_initial_sizex=this.resize_coords.grid.size_x; this.resize_initial_sizey=this.resize_coords.grid.size_y; this.resize_initial_col=this.resize_coords.grid.col; this.resize_last_sizex=this.resize_initial_sizex; this.resize_last_sizey=this.resize_initial_sizey; this.resize_max_size_x=Math.min(this.resize_wgd.max_size_x || this.options.resize.max_size[0], this.options.max_cols - this.resize_initial_col + 1); this.resize_max_size_y=this.resize_wgd.max_size_y || this.options.resize.max_size[1]; this.resize_min_size_x=(this.resize_wgd.min_size_x || this.options.resize.min_size[0]||1); this.resize_min_size_y=(this.resize_wgd.min_size_y || this.options.resize.min_size[1]||1); this.resize_initial_last_col=this.get_highest_occupied_cell().col; this.set_dom_grid_width(this.cols); this.resize_dir={ right: ui.$player.is('.' + this.resize_handle_class + '-x'), bottom: ui.$player.is('.' + this.resize_handle_class + '-y') }; this.$resized_widget.css({ 'min-width': this.options.widget_base_dimensions[0], 'min-height': this.options.widget_base_dimensions[1] }); var nodeName=this.$resized_widget.get(0).tagName; this.$resize_preview_holder=$('<' + nodeName + ' />', { 'class': 'preview-holder resize-preview-holder', 'data-row': this.$resized_widget.attr('data-row'), 'data-col': this.$resized_widget.attr('data-col'), 'css': { 'width': this.resize_initial_width, 'height': this.resize_initial_height }}).appendTo(this.$el); this.$resized_widget.addClass('resizing'); if(this.options.resize.start){ this.options.resize.start.call(this, event, ui, this.$resized_widget); } this.$el.trigger('gridster:resizestart'); }; fn.on_stop_resize=function(event, ui){ this.$resized_widget .removeClass('resizing') .css({ 'width': '', 'height': '' }); delay($.proxy(function(){ this.$resize_preview_holder .remove() .css({ 'min-width': '', 'min-height': '' }); if(this.options.resize.stop){ this.options.resize.stop.call(this, event, ui, this.$resized_widget); } this.$el.trigger('gridster:resizestop'); }, this), 300); this.set_dom_grid_width(); if(this.options.autogrow_cols){ this.drag_api.set_limits(this.cols * this.min_widget_width); }}; fn.on_resize=function(event, ui){ var rel_x=(ui.pointer.diff_left); var rel_y=(ui.pointer.diff_top); var wbd_x=this.options.widget_base_dimensions[0]; var wbd_y=this.options.widget_base_dimensions[1]; var margin_x=this.options.widget_margins[0]; var margin_y=this.options.widget_margins[1]; var max_size_x=this.resize_max_size_x; var min_size_x=this.resize_min_size_x; var max_size_y=this.resize_max_size_y; var min_size_y=this.resize_min_size_y; var autogrow=this.options.autogrow_cols; var width; var max_width=Infinity; var max_height=Infinity; var inc_units_x=Math.ceil((rel_x / (wbd_x + margin_x * 2)) - 0.2); var inc_units_y=Math.ceil((rel_y / (wbd_y + margin_y * 2)) - 0.2); var size_x=Math.max(1, this.resize_initial_sizex + inc_units_x); var size_y=Math.max(1, this.resize_initial_sizey + inc_units_y); var max_cols=(this.container_width / this.min_widget_width) - this.resize_initial_col + 1; var limit_width=((max_cols * this.min_widget_width) - margin_x * 2); size_x=Math.max(Math.min(size_x, max_size_x), min_size_x); size_x=Math.min(max_cols, size_x); width=(max_size_x * wbd_x) + ((size_x - 1) * margin_x * 2); max_width=Math.min(width, limit_width); min_width=(min_size_x * wbd_x) + ((size_x - 1) * margin_x * 2); size_y=Math.max(Math.min(size_y, max_size_y), min_size_y); max_height=(max_size_y * wbd_y) + ((size_y - 1) * margin_y * 2); min_height=(min_size_y * wbd_y) + ((size_y - 1) * margin_y * 2); if(this.resize_dir.right){ size_y=this.resize_initial_sizey; }else if(this.resize_dir.bottom){ size_x=this.resize_initial_sizex; } if(autogrow){ var last_widget_col=this.resize_initial_col + size_x - 1; if(autogrow&&this.resize_initial_last_col <=last_widget_col){ this.set_dom_grid_width(Math.max(last_widget_col + 1, this.cols)); if(this.cols < last_widget_col){ this.add_faux_cols(last_widget_col - this.cols); }} } var css_props={}; !this.resize_dir.bottom&&(css_props.width=Math.max(Math.min(this.resize_initial_width + rel_x, max_width), min_width)); !this.resize_dir.right&&(css_props.height=Math.max(Math.min(this.resize_initial_height + rel_y, max_height), min_height)); this.$resized_widget.css(css_props); if(size_x!==this.resize_last_sizex || size_y!==this.resize_last_sizey){ this.resize_widget(this.$resized_widget, size_x, size_y); this.set_dom_grid_width(this.cols); this.$resize_preview_holder.css({ 'width': '', 'height': '' }).attr({ 'data-row': this.$resized_widget.attr('data-row'), 'data-sizex': size_x, 'data-sizey': size_y }); } if(this.options.resize.resize){ this.options.resize.resize.call(this, event, ui, this.$resized_widget); } this.$el.trigger('gridster:resize'); this.resize_last_sizex=size_x; this.resize_last_sizey=size_y; }; fn.on_overlapped_column_change=function(start_callback, stop_callback){ if(!this.colliders_data.length){ return this; } var cols=this.get_targeted_columns(this.colliders_data[0].el.data.col); var last_n_cols=this.last_cols.length; var n_cols=cols.length; var i; for (i=0; i < n_cols; i++){ if($.inArray(cols[i], this.last_cols)===-1){ (start_callback||$.noop).call(this, cols[i]); }} for (i=0; i< last_n_cols; i++){ if($.inArray(this.last_cols[i], cols)===-1){ (stop_callback||$.noop).call(this, this.last_cols[i]); }} this.last_cols=cols; return this; }; fn.on_overlapped_row_change=function(start_callback, end_callback){ if(!this.colliders_data.length){ return this; } var rows=this.get_targeted_rows(this.colliders_data[0].el.data.row); var last_n_rows=this.last_rows.length; var n_rows=rows.length; var i; for (i=0; i < n_rows; i++){ if($.inArray(rows[i], this.last_rows)===-1){ (start_callback||$.noop).call(this, rows[i]); }} for (i=0; i < last_n_rows; i++){ if($.inArray(this.last_rows[i], rows)===-1){ (end_callback||$.noop).call(this, this.last_rows[i]); }} this.last_rows=rows; }; fn.set_player=function(col, row, no_player){ var self=this; if(!no_player){ this.empty_cells_player_occupies(); } var cell = !no_player ? self.colliders_data[0].el.data:{col: col}; var to_col=cell.col; var to_row=row||cell.row; this.player_grid_data={ col: to_col, row: to_row, size_y:this.player_grid_data.size_y, size_x:this.player_grid_data.size_x }; this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data); var $overlapped_widgets=this.get_widgets_overlapped(this.player_grid_data); var constraints=this.widgets_constraints($overlapped_widgets); this.manage_movements(constraints.can_go_up, to_col, to_row); this.manage_movements(constraints.can_not_go_up, to_col, to_row); if(!$overlapped_widgets.length){ var pp=this.can_go_player_up(this.player_grid_data); if(pp!==false){ to_row=pp; } this.set_placeholder(to_col, to_row); } return { col: to_col, row: to_row };}; fn.widgets_constraints=function($widgets){ var $widgets_can_go_up=$([]); var $widgets_can_not_go_up; var wgd_can_go_up=[]; var wgd_can_not_go_up=[]; $widgets.each($.proxy(function(i, w){ var $w=$(w); var wgd=$w.coords().grid; if(this.can_go_widget_up(wgd)){ $widgets_can_go_up=$widgets_can_go_up.add($w); wgd_can_go_up.push(wgd); }else{ wgd_can_not_go_up.push(wgd); }}, this)); $widgets_can_not_go_up=$widgets.not($widgets_can_go_up); return { can_go_up: Gridster.sort_by_row_asc(wgd_can_go_up), can_not_go_up: Gridster.sort_by_row_desc(wgd_can_not_go_up) };}; fn.manage_movements=function($widgets, to_col, to_row){ $.each($widgets, $.proxy(function(i, w){ var wgd=w; var $w=wgd.el; var can_go_widget_up=this.can_go_widget_up(wgd); if(can_go_widget_up){ this.move_widget_to($w, can_go_widget_up); this.set_placeholder(to_col, can_go_widget_up + wgd.size_y); }else{ var can_go_player_up=this.can_go_player_up(this.player_grid_data); if(!can_go_player_up){ var y=(to_row + this.player_grid_data.size_y) - wgd.row; this.move_widget_down($w, y); this.set_placeholder(to_col, to_row); }} }, this)); return this; }; fn.is_player=function(col_or_el, row){ if(row&&!this.gridmap[col_or_el]){ return false; } var $w=row ? this.gridmap[col_or_el][row]:col_or_el; return $w&&($w.is(this.$player)||$w.is(this.$helper)); }; fn.is_player_in=function(col, row){ var c=this.cells_occupied_by_player||{}; return $.inArray(col, c.cols) >=0&&$.inArray(row, c.rows) >=0; }; fn.is_placeholder_in=function(col, row){ var c=this.cells_occupied_by_placeholder||{}; return this.is_placeholder_in_col(col)&&$.inArray(row, c.rows) >=0; }; fn.is_placeholder_in_col=function(col){ var c=this.cells_occupied_by_placeholder||[]; return $.inArray(col, c.cols) >=0; }; fn.is_empty=function(col, row){ if(typeof this.gridmap[col]!=='undefined'){ if(typeof this.gridmap[col][row]!=='undefined' && this.gridmap[col][row]===false ){ return true; } return false; } return true; }; fn.is_occupied=function(col, row){ if(!this.gridmap[col]){ return false; } if(this.gridmap[col][row]){ return true; } return false; }; fn.is_widget=function(col, row){ var cell=this.gridmap[col]; if(!cell){ return false; } cell=cell[row]; if(cell){ return cell; } return false; }; fn.is_widget_under_player=function(col, row){ if(this.is_widget(col, row)){ return this.is_player_in(col, row); } return false; }; fn.get_widgets_under_player=function(cells){ cells||(cells=this.cells_occupied_by_player||{cols: [], rows: []}); var $widgets=$([]); $.each(cells.cols, $.proxy(function(i, col){ $.each(cells.rows, $.proxy(function(i, row){ if(this.is_widget(col, row)){ $widgets=$widgets.add(this.gridmap[col][row]); }}, this)); }, this)); return $widgets; }; fn.set_placeholder=function(col, row){ var phgd=$.extend({}, this.placeholder_grid_data); var $nexts=this.widgets_below({ col: phgd.col, row: phgd.row, size_y: phgd.size_y, size_x: phgd.size_x }); var right_col=(col + phgd.size_x - 1); if(right_col > this.cols){ col=col - (right_col - col); } var moved_down=this.placeholder_grid_data.row < row; var changed_column=this.placeholder_grid_data.col!==col; this.placeholder_grid_data.col=col; this.placeholder_grid_data.row=row; this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data); this.$preview_holder.attr({ 'data-row':row, 'data-col':col }); if(moved_down||changed_column){ $nexts.each($.proxy(function(i, widget){ this.move_widget_up($(widget), this.placeholder_grid_data.col - col + phgd.size_y); }, this)); } var $widgets_under_ph=this.get_widgets_under_player(this.cells_occupied_by_placeholder); if($widgets_under_ph.length){ $widgets_under_ph.each($.proxy(function(i, widget){ var $w=$(widget); this.move_widget_down($w, row + phgd.size_y - $w.data('coords').grid.row); }, this)); }}; fn.can_go_player_up=function(widget_grid_data){ var p_bottom_row=widget_grid_data.row + widget_grid_data.size_y - 1; var result=true; var upper_rows=[]; var min_row=10000; var $widgets_under_player=this.get_widgets_under_player(); this.for_each_column_occupied(widget_grid_data, function(tcol){ var grid_col=this.gridmap[tcol]; var r=p_bottom_row + 1; upper_rows[tcol]=[]; while (--r > 0){ if(this.is_empty(tcol, r)||this.is_player(tcol, r) || this.is_widget(tcol, r) && grid_col[r].is($widgets_under_player) ){ upper_rows[tcol].push(r); min_row=r < min_row ? r:min_row; }else{ break; }} if(upper_rows[tcol].length===0){ result=false; return true; } upper_rows[tcol].sort(function(a, b){ return a - b; }); }); if(!result){ return false; } return this.get_valid_rows(widget_grid_data, upper_rows, min_row); }; fn.can_go_widget_up=function(widget_grid_data){ var p_bottom_row=widget_grid_data.row + widget_grid_data.size_y - 1; var result=true; var upper_rows=[]; var min_row=10000; this.for_each_column_occupied(widget_grid_data, function(tcol){ var grid_col=this.gridmap[tcol]; upper_rows[tcol]=[]; var r=p_bottom_row + 1; while (--r > 0){ if(this.is_widget(tcol, r)&&!this.is_player_in(tcol, r)){ if(!grid_col[r].is(widget_grid_data.el)){ break; }} if(!this.is_player(tcol, r) && !this.is_placeholder_in(tcol, r) && !this.is_player_in(tcol, r)){ upper_rows[tcol].push(r); } if(r < min_row){ min_row=r; }} if(upper_rows[tcol].length===0){ result=false; return true; } upper_rows[tcol].sort(function(a, b){ return a - b; }); }); if(!result){ return false; } return this.get_valid_rows(widget_grid_data, upper_rows, min_row); }; fn.get_valid_rows=function(widget_grid_data, upper_rows, min_row){ var p_top_row=widget_grid_data.row; var p_bottom_row=widget_grid_data.row + widget_grid_data.size_y - 1; var size_y=widget_grid_data.size_y; var r=min_row - 1; var valid_rows=[]; while (++r <=p_bottom_row){ var common=true; $.each(upper_rows, function(col, rows){ if($.isArray(rows)&&$.inArray(r, rows)===-1){ common=false; }}); if(common===true){ valid_rows.push(r); if(valid_rows.length===size_y){ break; }} } var new_row=false; if(size_y===1){ if(valid_rows[0]!==p_top_row){ new_row=valid_rows[0]||false; }}else{ if(valid_rows[0]!==p_top_row){ new_row=this.get_consecutive_numbers_index(valid_rows, size_y); }} return new_row; }; fn.get_consecutive_numbers_index=function(arr, size_y){ var max=arr.length; var result=[]; var first=true; var prev=-1; for (var i=0; i < max; i++){ if(first||arr[i]===prev + 1){ result.push(i); if(result.length===size_y){ break; } first=false; }else{ result=[]; first=true; } prev=arr[i]; } return result.length >=size_y ? arr[result[0]]:false; }; fn.get_widgets_overlapped=function(){ var $w; var $widgets=$([]); var used=[]; var rows_from_bottom=this.cells_occupied_by_player.rows.slice(0); rows_from_bottom.reverse(); $.each(this.cells_occupied_by_player.cols, $.proxy(function(i, col){ $.each(rows_from_bottom, $.proxy(function(i, row){ if(!this.gridmap[col]){ return true; } var $w=this.gridmap[col][row]; if(this.is_occupied(col, row)&&!this.is_player($w) && $.inArray($w, used)===-1 ){ $widgets=$widgets.add($w); used.push($w); }}, this)); }, this)); return $widgets; }; fn.on_start_overlapping_column=function(col){ this.set_player(col, false); }; fn.on_start_overlapping_row=function(row){ this.set_player(false, row); }; fn.on_stop_overlapping_column=function(col){ this.set_player(col, false); var self=this; this.for_each_widget_below(col, this.cells_occupied_by_player.rows[0], function(tcol, trow){ self.move_widget_up(this, self.player_grid_data.size_y); }); }; fn.on_stop_overlapping_row=function(row){ this.set_player(false, row); var self=this; var cols=this.cells_occupied_by_player.cols; for (var c=0, cl=cols.length; c < cl; c++){ this.for_each_widget_below(cols[c], row, function(tcol, trow){ self.move_widget_up(this, self.player_grid_data.size_y); }); }}; fn.move_widget_to=function($widget, row){ var self=this; var widget_grid_data=$widget.coords().grid; var diff=row - widget_grid_data.row; var $next_widgets=this.widgets_below($widget); var can_move_to_new_cell=this.can_move_to(widget_grid_data, widget_grid_data.col, row, $widget); if(can_move_to_new_cell===false){ return false; } this.remove_from_gridmap(widget_grid_data); widget_grid_data.row=row; this.add_to_gridmap(widget_grid_data); $widget.attr('data-row', row); this.$changed=this.$changed.add($widget); $next_widgets.each(function(i, widget){ var $w=$(widget); var wgd=$w.coords().grid; var can_go_up=self.can_go_widget_up(wgd); if(can_go_up&&can_go_up!==wgd.row){ self.move_widget_to($w, can_go_up); }}); return this; }; fn.move_widget_up=function($widget, y_units){ var el_grid_data=$widget.coords().grid; var actual_row=el_grid_data.row; var moved=[]; var can_go_up=true; y_units||(y_units=1); if(!this.can_go_up($widget)){ return false; } this.for_each_column_occupied(el_grid_data, function(col){ if($.inArray($widget, moved)===-1){ var widget_grid_data=$widget.coords().grid; var next_row=actual_row - y_units; next_row=this.can_go_up_to_row(widget_grid_data, col, next_row); if(!next_row){ return true; } var $next_widgets=this.widgets_below($widget); this.remove_from_gridmap(widget_grid_data); widget_grid_data.row=next_row; this.add_to_gridmap(widget_grid_data); $widget.attr('data-row', widget_grid_data.row); this.$changed=this.$changed.add($widget); moved.push($widget); $next_widgets.each($.proxy(function(i, widget){ this.move_widget_up($(widget), y_units); }, this)); }}); }; fn.move_widget_down=function($widget, y_units){ var el_grid_data, actual_row, moved, y_diff; if(y_units <=0){ return false; } el_grid_data=$widget.coords().grid; actual_row=el_grid_data.row; moved=[]; y_diff=y_units; if(!$widget){ return false; } if($.inArray($widget, moved)===-1){ var widget_grid_data=$widget.coords().grid; var next_row=actual_row + y_units; var $next_widgets=this.widgets_below($widget); this.remove_from_gridmap(widget_grid_data); $next_widgets.each($.proxy(function(i, widget){ var $w=$(widget); var wd=$w.coords().grid; var tmp_y=this.displacement_diff(wd, widget_grid_data, y_diff); if(tmp_y > 0){ this.move_widget_down($w, tmp_y); }}, this)); widget_grid_data.row=next_row; this.update_widget_position(widget_grid_data, $widget); $widget.attr('data-row', widget_grid_data.row); this.$changed=this.$changed.add($widget); moved.push($widget); }}; fn.can_go_up_to_row=function(widget_grid_data, col, row){ var ga=this.gridmap; var result=true; var urc=[]; var actual_row=widget_grid_data.row; var r; this.for_each_column_occupied(widget_grid_data, function(tcol){ var grid_col=ga[tcol]; urc[tcol]=[]; r=actual_row; while (r--){ if(this.is_empty(tcol, r) && !this.is_placeholder_in(tcol, r) ){ urc[tcol].push(r); }else{ break; }} if(!urc[tcol].length){ result=false; return true; }}); if(!result){ return false; } r=row; for (r=1; r < actual_row; r++){ var common=true; for (var uc=0, ucl=urc.length; uc < ucl; uc++){ if(urc[uc]&&$.inArray(r, urc[uc])===-1){ common=false; }} if(common===true){ result=r; break; }} return result; }; fn.displacement_diff=function(widget_grid_data, parent_bgd, y_units){ var actual_row=widget_grid_data.row; var diffs=[]; var parent_max_y=parent_bgd.row + parent_bgd.size_y; this.for_each_column_occupied(widget_grid_data, function(col){ var temp_y_units=0; for (var r=parent_max_y; r < actual_row; r++){ if(this.is_empty(col, r)){ temp_y_units=temp_y_units + 1; }} diffs.push(temp_y_units); }); var max_diff=Math.max.apply(Math, diffs); y_units=(y_units - max_diff); return y_units > 0 ? y_units:0; }; fn.widgets_below=function($el){ var el_grid_data=$.isPlainObject($el) ? $el:$el.coords().grid; var self=this; var ga=this.gridmap; var next_row=el_grid_data.row + el_grid_data.size_y - 1; var $nexts=$([]); this.for_each_column_occupied(el_grid_data, function(col){ self.for_each_widget_below(col, next_row, function(tcol, trow){ if(!self.is_player(this)&&$.inArray(this, $nexts)===-1){ $nexts=$nexts.add(this); return true; }}); }); return Gridster.sort_by_row_asc($nexts); }; fn.set_cells_player_occupies=function(col, row){ this.remove_from_gridmap(this.placeholder_grid_data); this.placeholder_grid_data.col=col; this.placeholder_grid_data.row=row; this.add_to_gridmap(this.placeholder_grid_data, this.$player); return this; }; fn.empty_cells_player_occupies=function(){ this.remove_from_gridmap(this.placeholder_grid_data); return this; }; fn.can_go_up=function($el){ var el_grid_data=$el.coords().grid; var initial_row=el_grid_data.row; var prev_row=initial_row - 1; var ga=this.gridmap; var upper_rows_by_column=[]; var result=true; if(initial_row===1){ return false; } this.for_each_column_occupied(el_grid_data, function(col){ var $w=this.is_widget(col, prev_row); if(this.is_occupied(col, prev_row) || this.is_player(col, prev_row) || this.is_placeholder_in(col, prev_row) || this.is_player_in(col, prev_row) ){ result=false; return true; }}); return result; }; fn.can_move_to=function(widget_grid_data, col, row, max_row){ var ga=this.gridmap; var $w=widget_grid_data.el; var future_wd={ size_y: widget_grid_data.size_y, size_x: widget_grid_data.size_x, col: col, row: row }; var result=true; var right_col=col + widget_grid_data.size_x - 1; if(right_col > this.cols){ return false; } if(max_row&&max_row < row + widget_grid_data.size_y - 1){ return false; } this.for_each_cell_occupied(future_wd, function(tcol, trow){ var $tw=this.is_widget(tcol, trow); if($tw&&(!widget_grid_data.el||$tw.is($w))){ result=false; }}); return result; }; fn.get_targeted_columns=function(from_col){ var max=(from_col||this.player_grid_data.col) + (this.player_grid_data.size_x - 1); var cols=[]; for (var col=from_col; col <=max; col++){ cols.push(col); } return cols; }; fn.get_targeted_rows=function(from_row){ var max=(from_row||this.player_grid_data.row) + (this.player_grid_data.size_y - 1); var rows=[]; for (var row=from_row; row <=max; row++){ rows.push(row); } return rows; }; fn.get_cells_occupied=function(el_grid_data){ var cells={ cols: [], rows: []}; var i; if(arguments[1] instanceof $){ el_grid_data=arguments[1].coords().grid; } for (i=0; i < el_grid_data.size_x; i++){ var col=el_grid_data.col + i; cells.cols.push(col); } for (i=0; i < el_grid_data.size_y; i++){ var row=el_grid_data.row + i; cells.rows.push(row); } return cells; }; fn.for_each_cell_occupied=function(grid_data, callback){ this.for_each_column_occupied(grid_data, function(col){ this.for_each_row_occupied(grid_data, function(row){ callback.call(this, col, row); }); }); return this; }; fn.for_each_column_occupied=function(el_grid_data, callback){ for (var i=0; i < el_grid_data.size_x; i++){ var col=el_grid_data.col + i; callback.call(this, col, el_grid_data); }}; fn.for_each_row_occupied=function(el_grid_data, callback){ for (var i=0; i < el_grid_data.size_y; i++){ var row=el_grid_data.row + i; callback.call(this, row, el_grid_data); }}; fn._traversing_widgets=function(type, direction, col, row, callback){ var ga=this.gridmap; if(!ga[col]){ return; } var cr, max; var action=type + '/' + direction; if(arguments[2] instanceof $){ var el_grid_data=arguments[2].coords().grid; col=el_grid_data.col; row=el_grid_data.row; callback=arguments[3]; } var matched=[]; var trow=row; var methods={ 'for_each/above': function(){ while (trow--){ if(trow > 0&&this.is_widget(col, trow) && $.inArray(ga[col][trow], matched)===-1 ){ cr=callback.call(ga[col][trow], col, trow); matched.push(ga[col][trow]); if(cr){ break; }} }}, 'for_each/below': function(){ for (trow=row + 1, max=ga[col].length; trow < max; trow++){ if(this.is_widget(col, trow) && $.inArray(ga[col][trow], matched)===-1 ){ cr=callback.call(ga[col][trow], col, trow); matched.push(ga[col][trow]); if(cr){ break; }} }} }; if(methods[action]){ methods[action].call(this); }}; fn.for_each_widget_above=function(col, row, callback){ this._traversing_widgets('for_each', 'above', col, row, callback); return this; }; fn.for_each_widget_below=function(col, row, callback){ this._traversing_widgets('for_each', 'below', col, row, callback); return this; }; fn.get_highest_occupied_cell=function(){ var r; var gm=this.gridmap; var rl=gm[1].length; var rows=[], cols=[]; var row_in_col=[]; for (var c=gm.length - 1; c >=1; c--){ for (r=rl - 1; r >=1; r--){ if(this.is_widget(c, r)){ rows.push(r); cols.push(c); break; }} } return { col: Math.max.apply(Math, cols), row: Math.max.apply(Math, rows) };}; fn.get_widgets_from=function(col, row){ var ga=this.gridmap; var $widgets=$(); if(col){ $widgets=$widgets.add(this.$widgets.filter(function(){ var tcol=$(this).attr('data-col'); return (tcol===col||tcol > col); }) ); } if(row){ $widgets=$widgets.add(this.$widgets.filter(function(){ var trow=$(this).attr('data-row'); return (trow===row||trow > row); }) ); } return $widgets; }; fn.set_dom_grid_height=function(height){ if(typeof height==='undefined'){ var r=this.get_highest_occupied_cell().row; height=r * this.min_widget_height; } this.container_height=height; this.$el.css('height', this.container_height); return this; }; fn.set_dom_grid_width=function(cols){ if(typeof cols==='undefined'){ cols=this.get_highest_occupied_cell().col; } var max_cols=(this.options.autogrow_cols ? this.options.max_cols : this.cols); cols=Math.min(max_cols, Math.max(cols, this.options.min_cols)); this.container_width=cols * this.min_widget_width; this.$el.css('width', this.container_width); return this; }; fn.generate_stylesheet=function(opts){ var styles=''; var max_size_x=this.options.max_size_x||this.cols; var max_rows=0; var max_cols=0; var i; var rules; opts||(opts={}); opts.cols||(opts.cols=this.cols); opts.rows||(opts.rows=this.rows); opts.namespace||(opts.namespace=this.options.namespace); opts.widget_base_dimensions || (opts.widget_base_dimensions=this.options.widget_base_dimensions); opts.widget_margins || (opts.widget_margins=this.options.widget_margins); opts.min_widget_width=(opts.widget_margins[0] * 2) + opts.widget_base_dimensions[0]; opts.min_widget_height=(opts.widget_margins[1] * 2) + opts.widget_base_dimensions[1]; var serialized_opts=$.param(opts); if($.inArray(serialized_opts, Gridster.generated_stylesheets) >=0){ return false; } this.generated_stylesheets.push(serialized_opts); Gridster.generated_stylesheets.push(serialized_opts); for (i=opts.cols; i >=0; i--){ styles +=(opts.namespace + ' [data-col="'+ (i + 1) + '"] { left:' + ((i * opts.widget_base_dimensions[0]) + (i * opts.widget_margins[0]) + ((i + 1) * opts.widget_margins[0])) + 'px; }\n'); } for (i=opts.rows; i >=0; i--){ styles +=(opts.namespace + ' [data-row="' + (i + 1) + '"] { top:' + ((i * opts.widget_base_dimensions[1]) + (i * opts.widget_margins[1]) + ((i + 1) * opts.widget_margins[1])) + 'px; }\n'); } for (var y=1; y <=opts.rows; y++){ styles +=(opts.namespace + ' [data-sizey="' + y + '"] { height:' + (y * opts.widget_base_dimensions[1] + (y - 1) * (opts.widget_margins[1] * 2)) + 'px; }\n'); } for (var x=1; x <=max_size_x; x++){ styles +=(opts.namespace + ' [data-sizex="' + x + '"] { width:' + (x * opts.widget_base_dimensions[0] + (x - 1) * (opts.widget_margins[0] * 2)) + 'px; }\n'); } this.remove_style_tags(); return this.add_style_tag(styles); }; fn.add_style_tag=function(css){ var d=document; var tag=d.createElement('style'); d.getElementsByTagName('head')[0].appendChild(tag); tag.setAttribute('type', 'text/css'); if(tag.styleSheet){ tag.styleSheet.cssText=css; }else{ tag.appendChild(document.createTextNode(css)); } this.$style_tags=this.$style_tags.add(tag); return this; }; fn.remove_style_tags=function(){ var all_styles=Gridster.generated_stylesheets; var ins_styles=this.generated_stylesheets; this.$style_tags.remove(); Gridster.generated_stylesheets=$.map(all_styles, function(s){ if($.inArray(s, ins_styles)===-1){ return s; }}); }; fn.generate_faux_grid=function(rows, cols){ this.faux_grid=[]; this.gridmap=[]; var col; var row; for (col=cols; col > 0; col--){ this.gridmap[col]=[]; for (row=rows; row > 0; row--){ this.add_faux_cell(row, col); }} return this; }; fn.add_faux_cell=function(row, col){ var coords=$({ left: this.baseX + ((col - 1) * this.min_widget_width), top: this.baseY + (row -1) * this.min_widget_height, width: this.min_widget_width, height: this.min_widget_height, col: col, row: row, original_col: col, original_row: row }).coords(); if(!$.isArray(this.gridmap[col])){ this.gridmap[col]=[]; } this.gridmap[col][row]=false; this.faux_grid.push(coords); return this; }; fn.add_faux_rows=function(rows){ var actual_rows=this.rows; var max_rows=actual_rows + (rows||1); for (var r=max_rows; r > actual_rows; r--){ for (var c=this.cols; c >=1; c--){ this.add_faux_cell(r, c); }} this.rows=max_rows; if(this.options.autogenerate_stylesheet){ this.generate_stylesheet(); } return this; }; fn.add_faux_cols=function(cols){ var actual_cols=this.cols; var max_cols=actual_cols + (cols||1); max_cols=Math.min(max_cols, this.options.max_cols); for (var c=actual_cols + 1; c <=max_cols; c++){ for (var r=this.rows; r >=1; r--){ this.add_faux_cell(r, c); }} this.cols=max_cols; if(this.options.autogenerate_stylesheet){ this.generate_stylesheet(); } return this; }; fn.recalculate_faux_grid=function(){ var aw=this.$wrapper.width(); this.baseX=($(window).width() - aw) / 2; this.baseY=this.$wrapper.offset().top; $.each(this.faux_grid, $.proxy(function(i, coords){ this.faux_grid[i]=coords.update({ left: this.baseX + (coords.data.col -1) * this.min_widget_width, top: this.baseY + (coords.data.row -1) * this.min_widget_height }); }, this)); return this; }; fn.get_widgets_from_DOM=function(){ var widgets_coords=this.$widgets.map($.proxy(function(i, widget){ var $w=$(widget); return this.dom_to_coords($w); }, this)); widgets_coords=Gridster.sort_by_row_and_col_asc(widgets_coords); var changes=$(widgets_coords).map($.proxy(function(i, wgd){ return this.register_widget(wgd)||null; }, this)); if(changes.length){ this.$el.trigger('gridster:positionschanged'); } return this; }; fn.generate_grid_and_stylesheet=function(){ var aw=this.$wrapper.width(); var max_cols=this.options.max_cols; var cols=Math.floor(aw / this.min_widget_width) + this.options.extra_cols; var actual_cols=this.$widgets.map(function(){ return $(this).attr('data-col'); }).get(); actual_cols.length||(actual_cols=[0]); var min_cols=Math.max.apply(Math, actual_cols); this.cols=Math.max(min_cols, cols, this.options.min_cols); if(max_cols!==Infinity&&max_cols >=min_cols&&max_cols < this.cols){ this.cols=max_cols; } var max_rows=this.options.extra_rows; this.$widgets.each(function(i, w){ max_rows +=(+$(w).attr('data-sizey')); }); this.rows=Math.max(max_rows, this.options.min_rows); this.baseX=($(window).width() - aw) / 2; this.baseY=this.$wrapper.offset().top; if(this.options.autogenerate_stylesheet){ this.generate_stylesheet(); } return this.generate_faux_grid(this.rows, this.cols); }; fn.destroy=function(remove){ this.$el.removeData('gridster'); $(window).unbind('.gridster'); if(this.drag_api){ this.drag_api.destroy(); } this.remove_style_tags(); remove&&this.$el.remove(); return this; }; $.fn.gridster=function(options){ return this.each(function(){ if(! $(this).data('gridster')){ $(this).data('gridster', new Gridster(this, options)); }}); }; return Gridster; })); !function(a){a.idleTimer=function(b,c){var d;"object"==typeof b?(d=b,b=null):"number"==typeof b&&(d={timeout:b},b=null),c=c||document,d=a.extend({idle:!1,timeout:3e4,events:"mousemove keydown wheel DOMMouseScroll mousewheel mousedown touchstart touchmove MSPointerDown MSPointerMove"},d);var e=a(c),f=e.data("idleTimerObj")||{},g=function(b){var d=a.data(c,"idleTimerObj")||{};d.idle=!d.idle,d.olddate=+new Date;var e=a.Event((d.idle?"idle":"active")+".idleTimer");a(c).trigger(e,[c,a.extend({},d),b])},h=function(b){var d=a.data(c,"idleTimerObj")||{};if(null==d.remaining){if("mousemove"===b.type){if(b.pageX===d.pageX&&b.pageY===d.pageY)return;if("undefined"==typeof b.pageX&&"undefined"==typeof b.pageY)return;var e=+new Date-d.olddate;if(200>e)return}clearTimeout(d.tId),d.idle&&g(b),d.lastActive=+new Date,d.pageX=b.pageX,d.pageY=b.pageY,d.tId=setTimeout(g,d.timeout)}},i=function(){var b=a.data(c,"idleTimerObj")||{};b.idle=b.idleBackup,b.olddate=+new Date,b.lastActive=b.olddate,b.remaining=null,clearTimeout(b.tId),b.idle||(b.tId=setTimeout(g,b.timeout))},j=function(){var b=a.data(c,"idleTimerObj")||{};null==b.remaining&&(b.remaining=b.timeout-(+new Date-b.olddate),clearTimeout(b.tId))},k=function(){var b=a.data(c,"idleTimerObj")||{};null!=b.remaining&&(b.idle||(b.tId=setTimeout(g,b.remaining)),b.remaining=null)},l=function(){var b=a.data(c,"idleTimerObj")||{};clearTimeout(b.tId),e.removeData("idleTimerObj"),e.off("._idleTimer")},m=function(){var b=a.data(c,"idleTimerObj")||{};if(b.idle)return 0;if(null!=b.remaining)return b.remaining;var d=b.timeout-(+new Date-b.lastActive);return 0>d&&(d=0),d};if(null===b&&"undefined"!=typeof f.idle)return i(),e;if(null===b);else{if(null!==b&&"undefined"==typeof f.idle)return!1;if("destroy"===b)return l(),e;if("pause"===b)return j(),e;if("resume"===b)return k(),e;if("reset"===b)return i(),e;if("getRemainingTime"===b)return m();if("getElapsedTime"===b)return+new Date-f.olddate;if("getLastActiveTime"===b)return f.lastActive;if("isIdle"===b)return f.idle}return e.on(a.trim((d.events+" ").split(" ").join("._idleTimer ")),function(a){h(a)}),f=a.extend({},{olddate:+new Date,lastActive:+new Date,idle:d.idle,idleBackup:d.idle,timeout:d.timeout,remaining:null,tId:null,pageX:null,pageY:null}),f.idle||(f.tId=setTimeout(g,f.timeout)),a.data(c,"idleTimerObj",f),e},a.fn.idleTimer=function(b){return this[0]?a.idleTimer(b,this[0]):this}}(jQuery); (function($){ $(document).ready(function(){ var all_networks_opened=0; et_pb_fix_gallery_wrapper(); $('body').on('click', '.et_social_share', function(){ var $this_el=$(this), social_type=$this_el.data('social_type'), social_network=$this_el.data('social_name'), share_link='media'==social_type ? $this_el.data('social_link'):$this_el.prop('href'); update_stats_table(social_network, $this_el); if('like'===social_network){ return false; } var left=($(window).width()/2) -(550/2); var top=($(window).height()/2) -(450/2); var new_window=window.open(share_link, '', 'scrollbars=1, height=450, width=550, left=' + left + ', top=' + top); if(window.focus){ new_window.focus(); } return false; }); $('.et_social_follow').click(function(){ var $this_el=$(this), social_network=$this_el.data('social_name'); update_stats_table(social_network, $this_el); if('like'===social_network){ return false; }}); $('body').on('click', '.et_social_share_pinterest', function(){ if($(this).hasClass('et_social_pin_all')){ var left=($(window).width()/2) -(550/2), top=($(window).height()/2) -(450/2), share_link=$(this).attr('href'), new_window=window.open(share_link, '', 'scrollbars=1, height=450, width=550, left=' + left + ', top=' + top); if(window.focus){ new_window.focus(); }}else{ $('.et_social_pin_images_outer').fadeToggle(400); } return false; }); function get_url_parameter(param_name){ var page_url=window.location.search.substring(1); var url_variables=page_url.split('&'); for(var i=0; i < url_variables.length; i++){ var curr_param_name=url_variables[i].split('='); if(curr_param_name[0]==param_name){ return curr_param_name[1]; }} } function update_stats_table($social_network, $this_el){ var action=$this_el.data('social_type'), media_url='media'==action ? $this_el.closest('.et_social_media_wrapper').find('img').attr('src'):'', post_id=$this_el.data('post_id'), location=$this_el.data('location'), stats_data=''; stats_data=JSON.stringify({ 'action':action, 'network':$social_network, 'media_url':media_url, 'post_id':post_id, 'location':location }); $.ajax({ type: 'POST', url: monarchSettings.ajaxurl, data: { action:'add_stats_record_db', stats_data_array:stats_data, add_stats_nonce:monarchSettings.stats_nonce }, success: function(data){ if(true==data){ if('like'===action){ update_single_shares($this_el, '', post_id, $social_network, 'like'); } if('media'===action){ update_total_media_shares($this_el.closest('.et_social_media_wrapper')); update_single_shares($this_el, media_url, post_id, $social_network, 'media'); }} }}); } function append_share_counts($current_network){ var network=$current_network.data('social_name'), min_count=$current_network.data('min_count'), post_id=$current_network.data('post_id'), url=monarchSettings.pageurl!=='' ? monarchSettings.pageurl:window.location.href, label_div=$current_network.find('.et_social_network_label'), append_to=(0!=(label_div.length)) ? label_div:$current_network; $share_count_data=JSON.stringify({ 'network':network, 'min_count':min_count, 'post_id':post_id, 'url':url }); $.ajax({ type: 'POST', url: monarchSettings.ajaxurl, data: { action:'get_shares_count', share_count_array:$share_count_data, get_share_counts_nonce:monarchSettings.share_counts }, beforeSend: function(data){ append_to.append(''); }, success: function(data){ $current_network.find('span.et_social_placeholder').remove(); append_to.append(data); }}); } function append_total_shares($current_area){ var post_id=$current_area.data('post_id'), url=monarchSettings.pageurl!=='' ? monarchSettings.pageurl:window.location.href, append_to=$current_area; $share_total_count_data=JSON.stringify({ 'post_id':post_id, 'url':url }); $.ajax({ type: 'POST', url: monarchSettings.ajaxurl, data: { action:'get_total_shares', share_total_count_array:$share_total_count_data, get_total_counts_nonce:monarchSettings.total_counts }, beforeSend: function(data){ append_to.append(''); }, success: function(data){ append_to.find('span.et_social_placeholder').remove(); append_to.append(data); }}); } function append_follow_counts($current_area){ var network=$current_area.data('network'), min_count=$current_area.data('min_count'), index=$current_area.data('index'), append_to=$current_area; $follow_count_data=JSON.stringify({ 'network':network, 'min_count':min_count, 'index':index }); $.ajax({ type: 'POST', url: monarchSettings.ajaxurl, data: { action:'get_follow_counts', follow_count_array:$follow_count_data, get_follow_counts_nonce:monarchSettings.follow_counts }, beforeSend: function(data){ append_to.append(''); }, success: function(data){ $current_area.find('span.et_social_placeholder').remove(); append_to.append(data); }}); } function append_total_follows($current_area){ var append_to=$current_area; $.ajax({ type: 'POST', url: monarchSettings.ajaxurl, data: { action:'get_follow_total', get_total_counts_nonce:monarchSettings.total_counts }, beforeSend: function(data){ append_to.append(''); }, success: function(data){ append_to.find('span.et_social_placeholder').remove(); append_to.append(data); }}); } if($('.et_social_display_follow_counts').length){ $('.et_social_display_follow_counts').each(function(){ append_follow_counts($(this)); }); } if($('.et_social_follow_total').length){ $('.et_social_follow_total').each(function(){ append_total_follows($(this)); }); } if($('.et_social_total_share').length){ $('.et_social_total_share').each(function(){ append_total_shares($(this)); }); } if($('.et_social_display_count').length){ $('.et_social_display_count').each(function(){ append_share_counts($(this)); }); } if($('.et_social_media_wrapper').length&&$('.et_social_media_wrapper .et_social_totalcount').length){ $('.et_social_media_wrapper').each(function(){ update_total_media_shares($(this)); }); } if($('.et_social_media_wrapper').length&&$('.et_social_media_wrapper .et_social_withcounts').length){ $('.et_social_media_wrapper .et_social_share').each(function(){ var this_el=$(this), media_url=this_el.closest('.et_social_media_wrapper').find('img').attr('src'), post_id=this_el.data('post_id'), social_network=this_el.data('social_name'); update_single_shares(this_el, media_url, post_id, social_network, 'media'); }); } function update_total_media_shares($element){ if($('.et_social_totalcount').length){ var this_el=$element, media_url=this_el.find('img').attr('src'), post_id=this_el.find('.et_social_share').first().data('post_id'), media_data=JSON.stringify({ 'media_url':media_url, 'post_id':post_id }); $.ajax({ type: 'POST', url: monarchSettings.ajaxurl, data: { action:'get_media_shares_total', media_total:media_data, get_media_shares_total_nonce:monarchSettings.media_total }, success: function(data){ this_el.find('.et_social_totalcount_count').empty().append(data); }}); }} function update_single_shares($this_el, $media_url, $post_id, $network, $action){ if($('.et_social_withcounts').length){ var media_data=JSON.stringify({ 'media_url':$media_url, 'post_id':$post_id, 'network':$network, 'action':$action }); $.ajax({ type: 'POST', url: monarchSettings.ajaxurl, data: { action:'get_shares_single', media_single:media_data, get_media_shares_nonce:monarchSettings.media_single }, success: function(data){ $this_el.find('.et_social_count span').not('.et_social_count_label').empty().append(data); }}); }} function setCookieExpire(days){ var ms=days*24*60*60*1000; var date=new Date(); date.setTime(date.getTime() + ms); return "; expires=" + date.toUTCString(); } function checkCookieValue(cookieName, value){ return parseCookies()[cookieName]===value; } function parseCookies(){ var cookies=document.cookie.split('; '); var ret={}; for (var i=cookies.length - 1; i >=0; i--){ var el=cookies[i].split('='); ret[el[0]]=el[1]; } return ret; } function set_cookie($expire){ cookieExpire=setCookieExpire($expire); document.cookie='etSocialCookie=true' + cookieExpire; } function make_popup_visible($popup, $delay){ setTimeout(function(){ $popup.addClass('et_social_visible et_social_animated'); if($('.et_social_resize').length){ $('.et_social_resize').each(function(){ define_popup_position($(this)); }); }}, $delay); } function auto_popup(this_el, delay){ var $current_popup_auto=this_el; if(! $current_popup_auto.hasClass('et_social_animated')){ var $cookies_expire_auto=$current_popup_auto.data('cookie_duration') ? $current_popup_auto.data('cookie_duration'):false, $delay=delay; if(( false!==$cookies_expire_auto&&! checkCookieValue('etSocialCookie', 'true'))||false==$cookies_expire_auto){ make_popup_visible($current_popup_auto, $delay); if(false!==$cookies_expire_auto){ set_cookie($cookies_expire_auto); }} }} if('true'==get_url_parameter('et_monarch_popup')){ $('.et_social_after_comment').each(function(){ var $current_popup=$(this); auto_popup($current_popup, 0); }); } if($('.et_social_auto_popup').length){ $('.et_social_auto_popup').each(function(){ var $current_popup_auto=$(this); auto_popup($current_popup_auto, ''!==$current_popup_auto.data('delay') ? $current_popup_auto.data('delay') * 1000:0); }); } $('.et_social_pinterest_window .et_social_close').on('click', function(){ $('.et_social_pin_images_outer').fadeToggle(400); }); $('body').on('click', '.et_social_icon_cancel', function(){ var this_el=$(this); if(this_el.parent().hasClass('et_social_flyin')){ $popup=this_el.parent(); }else{ $popup=this_el.parent().parent(); if($popup.hasClass('et_social_all_networks_popup')){ all_networks_opened=0; }} $popup.addClass('et_social_fadeout'); setTimeout(function(){ $popup.remove(); }, 800); return false; }); if($('.et_monarch_after_order').length){ $('.et_social_after_purchase').each(function(){ var $current_popup=$(this); if(! $current_popup.hasClass('et_social_animated')){ var $cookies_expire=$current_popup.data('cookie_duration') ? $current_popup.data('cookie_duration'):false, $delay=0; if(( false!==$cookies_expire&&! checkCookieValue('etSocialCookie', 'true'))||false==$cookies_expire){ make_popup_visible($current_popup, $delay); if(false!==$cookies_expire){ set_cookie($cookies_expire); }} }}); } if($('.et_social_trigger_bottom').length){ $('.et_social_trigger_bottom').each(function(){ scroll_trigger($(this), true); }); } if($('.et_social_scroll').length){ $('.et_social_scroll').each(function(){ scroll_trigger($(this), false); }); } function scroll_trigger(this_el, is_bottom_trigger){ var current_popup_bottom=this_el; if(! current_popup_bottom.hasClass('et_social_animated')){ var cookies_expire_bottom=current_popup_bottom.data('cookie_duration') ? current_popup_bottom.data('cookie_duration'):false; if(true==is_bottom_trigger){ var scroll_trigger=$('.et_social_bottom_trigger').length ? $('.et_social_bottom_trigger').offset().top:$(document).height() - 500; }else{ var scroll_pos=this_el.data('scroll_pos') > 100 ? 100:this_el.data('scroll_pos'), scroll_trigger=100==scroll_pos ? $(document).height() - 10:$(document).height() * scroll_pos / 100; } $(window).scroll(function(){ if(( false!==cookies_expire_bottom&&! checkCookieValue('etSocialCookie', 'true'))||false==cookies_expire_bottom){ if($(window).scrollTop() + $(window).height() > scroll_trigger){ current_popup_bottom.addClass('et_social_visible et_social_animated'); if($('.et_social_resize').length){ $('.et_social_resize').each(function(){ define_popup_position($(this)); }); } if(false!==cookies_expire_bottom){ set_cookie(cookies_expire_bottom); }} }}); }} if($('.et_social_trigger_idle').length){ $('.et_social_trigger_idle').each(function(){ var this_el=$(this); if(! this_el.hasClass('et_social_animated')){ var $cookies_expire_idle=this_el.data('cookie_duration') ? this_el.data('cookie_duration'):false, $idle_timeout=''!==this_el.data('idle_timeout') ? this_el.data('idle_timeout') * 1000:30000; if(( false!==$cookies_expire_idle&&! checkCookieValue('etSocialCookie', 'true'))||false==$cookies_expire_idle){ $(document).idleTimer($idle_timeout); $(document).on("idle.idleTimer", function(){ make_popup_visible(this_el, 0); }); if(false!==$cookies_expire_idle){ set_cookie($cookies_expire_idle); }} }}); } $('.et_social_heading, .et_social_mobile_button').click(function(){ $this_mobile_div=$('.et_social_mobile'); $this_mobile_div.css({'display':'block' }); $('.et_social_mobile_button').removeClass('et_social_active_button'); if($this_mobile_div.hasClass('et_social_opened')){ $this_mobile_div.find('.et_social_networks').slideToggle(600); $this_mobile_div.removeClass('et_social_opened').addClass('et_social_closed'); $('.et_social_mobile_overlay').removeClass('et_social_visible_overlay'); $('.et_social_mobile_overlay').fadeToggle(600); }else{ $this_mobile_div.removeClass('et_social_closed').addClass('et_social_opened'); $this_mobile_div.find('.et_social_networks').slideToggle(600); $('.et_social_mobile_overlay').addClass('et_social_visible_overlay').css({ 'display':'block' }); }}); $('.et_social_mobile .et_social_close').click(function(){ $mobile_div=$('.et_social_mobile'); $mobile_div.fadeToggle(600); $('.et_social_mobile_button').addClass('et_social_active_button'); if($mobile_div.hasClass('et_social_opened')){ $('.et_social_mobile_overlay').fadeToggle(600); $mobile_div.removeClass('et_social_opened'); $mobile_div.find('.et_social_networks').fadeToggle(600); }}); if($('.et_social_inline').length){ if($('body').hasClass('et_pb_pagebuilder_layout')){ var top_inline=$('.et_social_inline_top'), bottom_inline=$('.et_social_inline_bottom'), divi_container='
'; if(top_inline.length){ $('.et_pb_section').not('.et_pb_fullwidth_section').first().prepend(divi_container).find('.et_pb_row').first().find('.et_pb_column').append(top_inline); } if(bottom_inline.length){ $('.et_pb_section').not('.et_pb_fullwidth_section').last().append(divi_container).find('.et_pb_row').last().find('.et_pb_column').append(bottom_inline); }} } function define_popup_position($this_popup){ setTimeout(function(){ var this_popup=$this_popup, networks_div=this_popup.find('.et_social_networks'), header_height=this_popup.find('.et_social_header').outerHeight(), total_count_height=this_popup.find('.et_social_totalcount').height(), extra_height=0 < total_count_height ? 20:0; this_popup.height(this_popup.find('.et_social_icons_container').innerHeight() + header_height + total_count_height + 20 + extra_height); var popup_max_height=this_popup.hasClass('et_social_popup_content') ? $(window).height():$(window).height() - 60; if(this_popup.hasClass('et_social_popup_content')&&768 < $(window).width()){ popup_max_height=popup_max_height - 50; } this_popup.css({ 'max-height':popup_max_height }); if(this_popup.hasClass('et_social_popup_content')){ var top_position=$(window).height() / 2 - this_popup.innerHeight() / 2; this_popup.css({ 'top':top_position + 'px' }); } var networks_div_height=this_popup.height() - header_height + total_count_height - extra_height; networks_div.height(networks_div_height); }, 400); } function set_mobile_sidebar_height(){ setTimeout(function(){ var mobile_div=$('.et_social_mobile'); if(!mobile_div.hasClass('et_social_opened')){ $('.et_social_mobile .et_social_networks').css({'display':'block'}); } if($('.et_social_active_button').length){ mobile_div.css({'display':'block'}); } var inner_contatiner_height=mobile_div.find('.et_social_icons_container').innerHeight() + 45; if(!mobile_div.hasClass('et_social_opened')){ $('.et_social_mobile .et_social_networks').css({'display':'none'}); } if($('.et_social_active_button').length){ mobile_div.css({'display':'none'}); } mobile_div.find('.et_social_networks').css({ 'max-height':inner_contatiner_height, 'height':inner_contatiner_height }); if($(window).height() < inner_contatiner_height){ var inner_height=$(window).height() - mobile_div.find('.et_social_heading').innerHeight() + 10; mobile_div.find('.et_social_networks').css({ 'height':inner_height }); }}, 400); } function set_sidebar_position(){ if($('.et_social_sidebar_networks').length){ var this_sidebar=$('.et_social_sidebar_networks'), top_position=$(window).height() / 2 - this_sidebar.innerHeight() / 2; top_position=0 > top_position ? 0:top_position; this_sidebar.css({ 'top':top_position + 'px' }); }} function set_media_wrapper_size(){ if($('.et_social_media_wrapper').length){ $('.et_social_media_wrapper').each(function(){ var this_wrapper=$(this), this_wrapper_media=this_wrapper.find('.et_social_media'), this_image=this_wrapper.find('img'), image_position=this_image.position(), image_left_offset=typeof image_position!=='undefined' ? image_position.left:0, this_image_height=this_image.height(), this_image_width=this_image.width(), this_wrapper_networks_height=this_wrapper.find('.et_social_networks').innerHeight(); this_wrapper.addClass(this_image.attr('class')); this_wrapper_media.css({ 'max-height':this_image_height }); this_wrapper_media.css({ 'height':this_wrapper_networks_height + 50 }); this_wrapper_media.width(this_image_width - 80); if(0!==image_left_offset){ this_wrapper_media.css({ 'left':image_left_offset + 20 }); }}); et_pb_fix_gallery_slider_icons_size(); }} function et_pb_fix_gallery_wrapper(){ var $media_wrappers_inside_gallery=$('.et_pb_gallery_grid .et_social_media_wrapper'); if(0 > $media_wrappers_inside_gallery.length){ return; } $media_wrappers_inside_gallery.each(function(){ var $this_wrapper=$(this); var $gallery_item=$this_wrapper.closest('.et_pb_gallery_image'); var $gallery_overlay=$gallery_item.find('.et_overlay'); if(0 < $gallery_overlay.length){ $this_wrapper.append($gallery_overlay); }}); } function et_pb_fix_gallery_slider_icons_size(){ var $gallery_slider_icons=$('.et_pb_gallery_fullwidth .et_social_media_wrapper'); if(0 > $gallery_slider_icons.length){ return; } var $all_galleries=$('.et_pb_gallery_fullwidth'); $all_galleries.each(function(){ var $this_gallery=$(this); var $this_gallery_media=$this_gallery.find('.et_social_media_wrapper .et_social_media'); if(0 > $this_gallery_media.length){ return; } var $first_icon_wrapper=$this_gallery_media.first(); var icons_width=$first_icon_wrapper.width(); var icons_height=$first_icon_wrapper.css('height'); var icons_max_height=$first_icon_wrapper.css('max-height'); $this_gallery_media.width(icons_width - 80); $this_gallery_media.height(icons_height); $this_gallery_media.css({ 'max-height':icons_max_height }); }); } $('body').on('click', '.et_social_open_all', function(){ all_networks_opened++; if(1==all_networks_opened){ var this_button=$(this), page_id=this_button.data('page_id'), permalink=this_button.data('permalink'), title=this_button.data('title'), media=typeof this_button.data('media')!=='undefined' ? this_button.data('media'):'', is_popup='popup'==this_button.data('location') ? 'true':'false'; $.ajax({ type: 'POST', url: monarchSettings.ajaxurl, data: { action:'generate_all_networks_popup', all_networks_page_id:page_id, all_networks_link:permalink, all_networks_title:title, all_networks_media:media, is_popup:is_popup, generate_all_window_nonce:monarchSettings.generate_all_window_nonce }, success: function(data){ if('false'==is_popup){ $('body').append(data); make_popup_visible($('.et_social_all_networks_popup'), 1); }else{ var popup_container=this_button.parent().closest('.et_social_popup_content'); this_button.parent().replaceWith(data); define_popup_position(popup_container); all_networks_opened=0; }} }); } return false; }); set_mobile_sidebar_height(); set_sidebar_position(); $(window).resize(function(){ if($('.et_social_resize').length){ $('.et_social_resize').each(function(){ define_popup_position($(this)); }); } if($('.et_social_mobile')){ set_mobile_sidebar_height(); } if($('.et_social_sidebar_networks').length){ set_sidebar_position(); } set_media_wrapper_size(); }); $('.et_social_hide_sidebar').click(function(){ $('.et_social_hide_sidebar').toggleClass('et_social_hidden_sidebar'); $('.et_social_sidebar_networks').toggleClass('et_social_hidden_sidebar et_social_visible_sidebar'); }); $(window).load(function(){ set_media_wrapper_size(); if($('.et_social_pin_images').length&&($('.et_social_all_button').length||$('.et_social_pinterest').length)){ var pin_container=$('.et_social_pin_images'), permalink=pin_container.data('permalink'), title=pin_container.data('title'), post_id=pin_container.data('post_id'), $i=0; $('img').each(function(){ if(! $(this).hasClass('avatar')){ var this_img=$(this).attr('src'), this_alt=$(this).attr('alt'); if(''!=this_img){ var pin_link='http://www.pinterest.com/pin/create/button/?url=' + permalink + '&media=' + this_img + '&description=' + title, this_img_container='
' + this_alt + '
'; $('.et_social_pin_images').append(this_img_container); $i++; }} }); if(0==$i){ $('.et_social_pin_images').append(monarchSettings.no_img_message); }} }); }); })(jQuery); !function($){$.fn.et_shortcodes_switcher=function(options){var defaults={slides:">div",activeClass:"active",linksNav:"",findParent:!0,lengthElement:"li",useArrows:!1,arrowLeft:"a#prev-arrow",arrowRight:"a#next-arrow",auto:!1,autoSpeed:5e3,slidePadding:"",pauseOnHover:!0,fx:"fade",sliderType:""},options=$.extend(defaults,options);return this.each(function(){function changeTab(){""!=linkSwitcherTab&&(linkSwitcherTab.siblings().removeClass("active"),linkSwitcherTab.filter(":eq("+(currentPosition-1)+")").addClass("active"))}function gotoSlide(slideNumber,dir){if(!$slide.filter(":animated").length&&($activeSlide=$slide.parent().find(".et_slidecontent").filter(":eq("+(currentPosition-1)+")"),currentPosition!==slideNumber))return $activeSlide.removeClass("et_shortcode_slide_active"),$nextSlide=$slide.parent().find(".et_slidecontent").filter(":eq("+(slideNumber-1)+")").addClass("et_shortcode_slide_active"),(currentPosition>slideNumber||1===currentPosition)&&-1===dir?("slide"===options.fx&&slideBack(500),"fade"===options.fx&&slideFade(500)):("slide"===options.fx&&slideForward(500),"fade"===options.fx&&slideFade(500)),currentPosition=$nextSlide.prevAll(".et_slidecontent").length+1,""!=options.linksNav&&changeTab(),"images"!==options.sliderType&&"simple"!==options.sliderType||($et_shortcodes_mobile_controls.find("li").removeClass("et_shortcodes_active_control"),$et_shortcodes_mobile_controls.find("li").eq(currentPosition-1).addClass("et_shortcodes_active_control")),!1}function slideFade(speed){$activeSlide.css({display:"none",opacity:"0"}),$nextSlide.css({opacity:"0",display:"block"}).animate({opacity:1},700)}function slideForward(speed){var next_slide_order=$nextSlide.prevAll(".et_slidecontent").length+1,go_to_first_slide=!1;$activeSlide.next(".et_slidecontent_cloned").length&&(next_slide_order=$activeSlide.prevAll().length+1,go_to_first_slide=!0),$slides_wrapper_box.animate({left:-$slides_wrapper.width()*next_slide_order},500,function(){go_to_first_slide&&$slides_wrapper_box.css("left",-$slides_wrapper.width())})}function slideBack(speed){var next_slide_order=$nextSlide.prevAll(".et_slidecontent").length+1,go_to_last_slide=!1;$activeSlide.prev(".et_slidecontent_cloned").length&&(next_slide_order=0,go_to_last_slide=!0),$slides_wrapper_box.animate({left:-$slides_wrapper.width()*next_slide_order},500,function(){go_to_last_slide&&$slides_wrapper_box.css("left",-$slides_wrapper.width()*slidesNum)})}function et_shortcodes_go_to_next_slide(){currentPosition===slidesNum?gotoSlide(1,1):gotoSlide(currentPosition+1),""!=options.linksNav&&changeTab()}function et_shortcodes_go_to_previous_slide(){1===currentPosition?gotoSlide(slidesNum,-1):gotoSlide(currentPosition-1,-1),""!=options.linksNav&&changeTab()}var $activeSlide,$nextSlide,$et_shortcodes_mobile_nav,$et_shortcodes_mobile_controls,slidesContainer=jQuery(this).parent().css("position","relative"),$slides=jQuery(this).css({overflow:"hidden",position:"relative"}),$slides_wrapper_box=slidesContainer.find(".et-tabs-content-wrapper"),$slides_wrapper=$slides_wrapper_box.parent(),$slide=$slides.find(".et-tabs-content-wrapper"+options.slides),slidesNum=$slide.length,currentPosition=1,slides_wrapper_width=$slides_wrapper.width();if("slide"===options.fx&&($slides_wrapper_box.width(200*(slidesNum+2)+"%"),$slide.css({width:slides_wrapper_width,visibility:"visible"}),$slides_wrapper_box.append($slide.filter(":first").clone().removeClass().addClass("et_slidecontent_cloned")),$slides_wrapper_box.prepend($slide.filter(":last").clone().removeClass().addClass("et_slidecontent_cloned")),$slides_wrapper_box.css("left",-slides_wrapper_width)),$slide.filter(":first").css({display:"block"}).addClass("et_shortcode_slide_active"),""!=options.slidePadding&&$slide.css("padding",options.slidePadding),""!=options.linksNav){var linkSwitcher=jQuery(options.linksNav),linkSwitcherTab="";(linkSwitcherTab=options.findParent?linkSwitcher.parent():linkSwitcher).filter(".active").length||linkSwitcherTab.filter(":first").addClass("active"),linkSwitcher.click(function(){var targetElement,orderNum;return targetElement=options.findParent?jQuery(this).parent():jQuery(this),(orderNum=targetElement.prevAll(options.lengthElement).length+1)>currentPosition?gotoSlide(orderNum,1):gotoSlide(orderNum,-1),!1})}if(options.useArrows){var $right_arrow=jQuery(options.arrowRight),$left_arrow=jQuery(options.arrowLeft);$right_arrow.click(function(){return et_shortcodes_go_to_next_slide(),!1}),$left_arrow.click(function(){return et_shortcodes_go_to_previous_slide(),!1})}if(options.auto){interval_shortcodes=setInterval(function(){pauseSlider||(currentPosition===slidesNum?gotoSlide(1,1):gotoSlide(currentPosition+1,1),""!=options.linksNav&&changeTab())},options.autoSpeed);var pauseSlider=!1}options.pauseOnHover&&slidesContainer.hover(function(){pauseSlider=!0},function(){pauseSlider=!1}),"slide"===options.fx&&$(window).resize(function(){$slides_wrapper_box.find(">div").css({width:$slides_wrapper.width()}),$slides_wrapper_box.css("left",-$slides_wrapper.width()*currentPosition)}),function(){var et_shortcodes_slides_num=slidesContainer.find(".et_slidecontent").length,et_shortcodes_controllers_html="";if(et_shortcodes_slides_num>1&&("images"===options.sliderType||"simple"===options.sliderType)){slidesContainer.append('
"),$et_shortcodes_mobile_controls=slidesContainer.find(".et_shortcodes_controls");for(var i=0;i';$et_shortcodes_mobile_controls.prepend(et_shortcodes_controllers_html),$et_shortcodes_mobile_controls.find("li:first").addClass("et_shortcodes_active_control"),$et_shortcodes_mobile_controls.find("a").click(function(){var this_order=$(this).parent("li").prevAll().length+1;return this_order!=currentPosition&&(this_order>currentPosition?gotoSlide(this_order,1):gotoSlide(this_order,-1),!1)}),($et_shortcodes_mobile_nav=slidesContainer.find(".et_shortcodes_controls_arrows")).find("a").click(function(){var et_active_slide_order,$this_link=jQuery(this);return $this_link.hasClass("et_sc_nav_next")&&et_shortcodes_go_to_next_slide(),$this_link.hasClass("et_sc_nav_prev")&&et_shortcodes_go_to_previous_slide(),$et_shortcodes_mobile_controls.find("li").removeClass("et_shortcodes_active_control"),et_active_slide_order=currentPosition-1,$et_shortcodes_mobile_controls.find("li").eq(et_active_slide_order).addClass("et_shortcodes_active_control"),!1})}else"images"!==options.sliderType&&"simple"!==options.sliderType&&(slidesContainer.prepend('"),($et_shortcodes_mobile_nav=slidesContainer.find(".et_shortcodes_mobile_nav")).find("a").click(function(){var $this_link=jQuery(this);return $this_link.hasClass("et_sc_nav_next")&&et_shortcodes_go_to_next_slide(),$this_link.hasClass("et_sc_nav_prev")&&et_shortcodes_go_to_previous_slide(),!1}))}()})},window.et_shortcodes_init=function($container){var $processed_container=void 0!==$container?$container:$("body"),$et_pricing_table_button=$processed_container.find(".pricing-table a.icon-button");$et_tooltip=$processed_container.find(".et-tooltip"),$et_tooltip.on("mouseover mouseout",function(event){"mouseover"==event.type?$(this).find(".et-tooltip-box").stop(!0,!0).animate({opacity:"show",bottom:"25px"},300):$(this).find(".et-tooltip-box").delay(200).animate({opacity:"hide",bottom:"35px"},300)}),$et_learn_more=$processed_container.find(".et-learn-more .heading-more"),$et_learn_more.on("click",function(){$(this).hasClass("open")?$(this).removeClass("open"):$(this).addClass("open"),$(this).parent(".et-learn-more").find(".learn-more-content").animate({opacity:"toggle",height:"toggle"},300)}),$processed_container.find(".et-learn-more").not(".et-open").find(".learn-more-content").css({visibility:"visible",display:"none"}),$et_pricing_table_button.each(function(){var $this_button=$(this),this_button_width=$this_button.width(),this_button_innerwidth=$this_button.innerWidth();$this_button.css({width:this_button_width,marginLeft:"-"+this_button_innerwidth/2+"px",visibility:"visible"})}),$processed_container.find(".et-tabs-container, .tabs-left, .et-simple-slider, .et-image-slider").each(function(i){var et_shortcodes_tab_class=$(this).attr("class"),et_shortcodes_tab_autospeed=/et_sliderauto_speed_(\d+)/g.exec(et_shortcodes_tab_class),et_shortcodes_tab_auto=/et_sliderauto_(\w+)/g.exec(et_shortcodes_tab_class),et_shortcodes_tab_type=/et_slidertype_(\w+)/g.exec(et_shortcodes_tab_class),et_shortcodes_tab_fx=/et_sliderfx_(\w+)/g.exec(et_shortcodes_tab_class),et_shortcodes_tab_apply_to_element=".et-tabs-content",et_shortcodes_tab_settings={};et_shortcodes_tab_settings.linksNav=$(this).find(".et-tabs-control li a"),et_shortcodes_tab_settings.findParent=!0,et_shortcodes_tab_settings.fx=et_shortcodes_tab_fx[1],et_shortcodes_tab_settings.auto="false"!==et_shortcodes_tab_auto[1],et_shortcodes_tab_settings.autoSpeed=et_shortcodes_tab_autospeed[1],"simple"===et_shortcodes_tab_type[1]?((et_shortcodes_tab_settings={}).fx=et_shortcodes_tab_fx[1],et_shortcodes_tab_settings.auto="false"!==et_shortcodes_tab_auto[1],et_shortcodes_tab_settings.autoSpeed=et_shortcodes_tab_autospeed[1],et_shortcodes_tab_settings.sliderType="simple",et_shortcodes_tab_apply_to_element=".et-simple-slides"):"images"===et_shortcodes_tab_type[1]&&(et_shortcodes_tab_settings.sliderType="images",et_shortcodes_tab_settings.linksNav="#"+$(this).attr("id")+" .controllers a.switch",et_shortcodes_tab_settings.findParent=!1,et_shortcodes_tab_settings.lengthElement="#"+$(this).attr("id")+" a.switch",et_shortcodes_tab_apply_to_element=".et-image-slides"),$(this).find(et_shortcodes_tab_apply_to_element).et_shortcodes_switcher(et_shortcodes_tab_settings)})}}(jQuery),jQuery(document).ready(function($){window.et_shortcodes_init()}); !function($){var $et_window=$(window);window.et_load_event_fired=!1,window.et_is_transparent_nav=$("body").hasClass("et_transparent_nav"),window.et_is_vertical_nav=$("body").hasClass("et_vertical_nav"),window.et_is_fixed_nav=$("body").hasClass("et_fixed_nav"),window.et_is_minified_js=$("body").hasClass("et_minified_js"),window.et_is_minified_css=$("body").hasClass("et_minified_css"),window.et_force_width_container_change=!1,jQuery.fn.reverse=[].reverse,jQuery.fn.closest_descendent=function(selector){for(var $found,$current_children=this.children();$current_children.length&&!($found=$current_children.filter(selector)).length;)$current_children=$current_children.children();return $found},window.et_pb_init_modules=function(){function process_et_hashchange(hash){if(-1!==hash.indexOf(et_hash_module_seperator,0)){modules=hash.split(et_hash_module_seperator);for(var i=0;i1&&!$et_slider.hasClass("et_slider_hovered")&&(et_slider_timer=setTimeout(function(){$et_slider.et_slider_move_to("next")},settings.slideshow_speed))}function et_stop_video(active_slide){var $et_video,et_video_src;active_slide.has("iframe").length?(et_video_src=($et_video=active_slide.find("iframe")).attr("src"),$et_video.attr("src",""),$et_video.attr("src",et_video_src)):active_slide.has("video").length&&(active_slide.find(".et_pb_section_video_bg").length||($et_video=active_slide.find("video"))[0].pause())}function et_fix_slider_content_images(){var $this_slider=$et_slider,$slide_image_container=$this_slider.find(".et-pb-active-slide .et_pb_slide_image"),$slide_video_container=$this_slider.find(".et-pb-active-slide .et_pb_slide_video"),$slide=$slide_image_container.closest(".et_pb_slide"),$slider=$slide.closest(".et_pb_slider"),slide_height=parseFloat($slider.innerHeight()),image_height=parseFloat(.8*slide_height),slide_image_container_height=parseFloat($slide_image_container.height()),slide_video_container_height=parseFloat($slide_video_container.height());isNaN(image_height)||($slide_image_container.find("img").css("maxHeight",image_height+"px"),slide_image_container_height=parseInt($slide_image_container.height())),!isNaN(slide_image_container_height)&&$slide.hasClass("et_pb_media_alignment_center")&&$slide_image_container.css("marginTop","-"+slide_image_container_height/2+"px"),isNaN(slide_video_container_height)||$slide_video_container.css("marginTop","-"+slide_video_container_height/2+"px")}function et_get_bg_layout_color($slide){return $slide.hasClass("et_pb_bg_layout_light")?"et_pb_bg_layout_light":"et_pb_bg_layout_dark"}function et_maybe_set_controls_color($slide){var next_slide_dot_color,$arrows,arrows_color;void 0!==$et_slider_controls&&$et_slider_controls.length&&(""!==(next_slide_dot_color=$slide.attr("data-dots_color")||"")?($et_slider_controls.attr("style","background-color: "+hex_to_rgba(next_slide_dot_color,"0.3")+";"),$et_slider_controls.filter(".et-pb-active-control").attr("style","background-color: "+hex_to_rgba(next_slide_dot_color)+"!important;")):$et_slider_controls.removeAttr("style")),void 0!==$et_slider_arrows&&$et_slider_arrows.length&&($arrows=$et_slider_arrows.find("a"),""!==(arrows_color=$slide.attr("data-arrows_color")||"")?$arrows.attr("style","color: "+arrows_color+"!important;"):$arrows.css("color","inherit"))}function et_fix_builder_content(){is_post_slider&&setTimeout(function(){var $et_pb_circle_counter=$(".et_pb_circle_counter"),$et_pb_number_counter=$(".et_pb_number_counter");window.et_fix_testimonial_inner_width(),$et_pb_circle_counter.length&&window.et_pb_reinit_circle_counters($et_pb_circle_counter),$et_pb_number_counter.length&&window.et_pb_reinit_number_counters($et_pb_number_counter),window.et_reinit_waypoint_modules()},1e3)}function hex_to_rgba(color,alpha){var rgba,color_16=parseInt(color.replace("#",""),16);return rgba=(color_16>>16&255)+","+(color_16>>8&255)+","+(255&color_16)+","+(alpha=alpha||1),rgba="rgba("+rgba+")"}var $et_slider_arrows,$et_slider_controls,$et_slider_carousel_controls,et_slider_timer,settings=$.extend({slide:".et-slide",arrows:".et-pb-slider-arrows",prev_arrow:".et-pb-arrow-prev",next_arrow:".et-pb-arrow-next",controls:".et-pb-controllers a",carousel_controls:".et_pb_carousel_item",control_active_class:"et-pb-active-control",previous_text:et_pb_custom.previous,next_text:et_pb_custom.next,fade_speed:500,use_arrows:!0,use_controls:!0,manual_arrows:"",append_controls_to:"",controls_below:!1,controls_class:"et-pb-controllers",slideshow:!1,slideshow_speed:7e3,show_progress_bar:!1,tabs_animation:!1,use_carousel:!1},options),$et_slider=$(el),$et_slide=$et_slider.closest_descendent(settings.slide),et_slides_number=$et_slide.length,et_fade_speed=settings.fade_speed,et_active_slide=0,controls_html="",carousel_html="",is_post_slider=($et_slider.find(".et_pb_container").width(),$et_slider.hasClass("et_pb_post_slider"));if($et_slider.et_animation_running=!1,$.data(el,"et_pb_simple_slider",$et_slider),$et_slide.eq(0).addClass("et-pb-active-slide"),settings.tabs_animation||$et_slider.hasClass("et_pb_bg_layout_dark")||$et_slider.hasClass("et_pb_bg_layout_light")||$et_slider.addClass(et_get_bg_layout_color($et_slide.eq(0))),settings.use_arrows&&et_slides_number>1&&(""==settings.manual_arrows?$et_slider.append('"):$et_slider.append(settings.manual_arrows),$et_slider_arrows=$et_slider.find(settings.arrows),$et_slider.find(settings.prev_arrow),$et_slider.find(settings.next_arrow),$et_slider.on("click.et_pb_simple_slider",settings.next_arrow,function(){return!$et_slider.et_animation_running&&($et_slider.et_slider_move_to("next"),!1)}),$et_slider.on("click.et_pb_simple_slider",settings.prev_arrow,function(){return!$et_slider.et_animation_running&&($et_slider.et_slider_move_to("previous"),!1)}),$et_slider.on("swipeleft.et_pb_simple_slider",settings.slide,function(event){$(event.target).closest(".et-fb-popover-tinymce").length||$(event.target).closest(".et-fb-editable-element").length||$et_slider.et_slider_move_to("next")}),$et_slider.on("swiperight.et_pb_simple_slider",settings.slide,function(event){$(event.target).closest(".et-fb-popover-tinymce").length||$(event.target).closest(".et-fb-editable-element").length||$et_slider.et_slider_move_to("previous")})),settings.use_controls&&et_slides_number>1){for(i=1;i<=et_slides_number;i++)controls_html+='"+i+"";$et_slider.find("video").length>0&&(settings.controls_class+=" et-pb-controllers-has-video-tag"),controls_html='
'+controls_html+"
",""==settings.append_controls_to?$et_slider.append(controls_html):$(settings.append_controls_to).append(controls_html),($et_slider_controls=settings.controls_below?$et_slider.parent().find(settings.controls):$et_slider.find(settings.controls)).on("click.et_pb_simple_slider",function(){return!$et_slider.et_animation_running&&($et_slider.et_slider_move_to($(this).index()),!1)})}if(et_maybe_set_controls_color($et_slide.eq(0)),settings.use_carousel&&et_slides_number>1){for(var i=1;i<=et_slides_number;i++)slide_id=i-1,image_src=void 0!==$et_slide.eq(slide_id).data("image")?"url("+$et_slide.eq(slide_id).data("image")+")":"none",carousel_html+='';carousel_html='",$et_slider.after(carousel_html),($et_slider_carousel_controls=$et_slider.siblings(".et_pb_carousel").find(settings.carousel_controls)).on("click.et_pb_simple_slider",function(){if($et_slider.et_animation_running)return!1;var $this=$(this);return $et_slider.et_slider_move_to($this.data("slide-id")),!1})}settings.slideshow&&et_slides_number>1&&$et_slider.on("mouseenter.et_pb_simple_slider",function(){$et_slider.hasClass("et_slider_auto_ignore_hover")||($et_slider.addClass("et_slider_hovered"),void 0!==et_slider_timer&&clearInterval(et_slider_timer))}).on("mouseleave.et_pb_simple_slider",function(){$et_slider.hasClass("et_slider_auto_ignore_hover")||($et_slider.removeClass("et_slider_hovered"),et_slider_auto_rotate())}),et_slider_auto_rotate(),$et_slider.et_slider_destroy=function(){void 0!==et_slider_timer&&clearInterval(et_slider_timer),$et_slider.off(".et_pb_simple_slider"),$et_slider.find(".et_pb_slide").css({"z-index":"",display:"",opacity:""}),$et_slider.find(".et-pb-active-slide").removeClass("et-pb-active-slide"),$et_slider.find(".et-pb-moved-slide").removeClass("et-pb-moved-slide"),$et_slider.find(".et-pb-slider-arrows, .et-pb-controllers").remove(),$et_slider.siblings(".et_pb_carousel").remove(),$et_slider.removeData("et_pb_simple_slider")},$et_slider.et_fix_slider_content_images=et_fix_slider_content_images,window.et_load_event_fired?et_fix_slider_height($et_slider):$et_window.on("load",function(){et_fix_slider_height($et_slider)}),$et_window.on("resize.et_simple_slider",function(){et_fix_slider_height($et_slider)}),$et_slider.et_slider_move_to=function(direction){var $active_slide=$et_slide.eq(et_active_slide);if($et_slider.et_animation_running=!0,$et_slider.removeClass("et_slide_transition_to_next et_slide_transition_to_previous").addClass("et_slide_transition_to_"+direction),$et_slider.find(".et-pb-moved-slide").removeClass("et-pb-moved-slide"),"next"==direction||"previous"==direction)et_active_slide="next"==direction?et_active_slide+1=0?et_active_slide-1:et_slides_number-1;else{if(et_active_slide==direction)return void($et_slider.et_animation_running=!1);et_active_slide=direction}void 0!==et_slider_timer&&clearInterval(et_slider_timer);var $next_slide=$et_slide.eq(et_active_slide);$et_slider.trigger("slide",{current:$active_slide,next:$next_slide}),void 0!==$active_slide.find("video")[0]&&void 0!==$active_slide.find("video")[0].player&&$active_slide.find("video")[0].player.pause(),void 0!==$next_slide.find("video")[0]&&void 0!==$next_slide.find("video")[0].player&&$next_slide.find("video")[0].player.play();var $active_slide_video=$active_slide.find(".et_pb_video_box iframe");if($active_slide_video.length){var active_slide_video_src=$active_slide_video.attr("src");active_slide_video_src=active_slide_video_src.replace(/\?autoplay=1$/,""),active_slide_video_src=active_slide_video_src.replace(/\?autoplay=1&(amp;)?/,"?"),active_slide_video_src=active_slide_video_src.replace(/&(amp;)?autoplay=1/,""),setTimeout(function(){$active_slide_video.attr({src:active_slide_video_src})},settings.fade_speed),$active_slide_video.parents(".et_pb_video_box").next(".et_pb_video_overlay").css({display:"block",opacity:1})}$et_slider.trigger("simple_slider_before_move_to",{direction:direction,next_slide:$next_slide}),$et_slide.each(function(){$(this).css("zIndex",1)}),$active_slide.css("zIndex",2).removeClass("et-pb-active-slide").addClass("et-pb-moved-slide").data("slide-status","inactive"),$next_slide.css({display:"block",opacity:0}).addClass("et-pb-active-slide").data("slide-status","active"),et_fix_slider_content_images(),et_fix_builder_content(),settings.use_controls&&$et_slider_controls.removeClass(settings.control_active_class).eq(et_active_slide).addClass(settings.control_active_class),settings.use_carousel&&$et_slider_carousel_controls&&$et_slider_carousel_controls.removeClass(settings.control_active_class).eq(et_active_slide).addClass(settings.control_active_class),settings.tabs_animation?($next_slide.css({display:"none",opacity:0}),$active_slide.addClass("et_slide_transition").css({display:"block",opacity:1}).animate({opacity:0},et_fade_speed,function(){$(this).css("display","none").removeClass("et_slide_transition"),$next_slide.css({display:"block",opacity:0}).animate({opacity:1},et_fade_speed,function(){$et_slider.et_animation_running=!1,$et_slider.trigger("simple_slider_after_move_to",{next_slide:$next_slide})})})):(et_maybe_set_controls_color($next_slide),$next_slide.animate({opacity:1},et_fade_speed),$active_slide.addClass("et_slide_transition").css({display:"list-item",opacity:1}).animate({opacity:0},et_fade_speed,function(){var active_slide_layout_bg_color=et_get_bg_layout_color($active_slide),next_slide_layout_bg_color=et_get_bg_layout_color($next_slide);$(this).css("display","none").removeClass("et_slide_transition"),et_stop_video($active_slide),$et_slider.removeClass(active_slide_layout_bg_color).addClass(next_slide_layout_bg_color),$et_slider.et_animation_running=!1,$et_slider.trigger("simple_slider_after_move_to",{next_slide:$next_slide})})),$next_slide.find(".et_parallax_bg").length&&window.et_pb_parallax_init($next_slide.find(".et_parallax_bg")),et_slider_auto_rotate()}},$.fn.et_pb_simple_slider=function(options){return this.each(function(){var slider=$.data(this,"et_pb_simple_slider");return slider||new $.et_pb_simple_slider(this,options)})};var et_hash_module_seperator="||",et_hash_module_param_seperator="|";$.et_pb_simple_carousel=function(el,options){function set_carousel_height($the_carousel){$the_carousel_items.width();var carousel_items_height=$the_carousel_items.height();$the_carousel.parent().hasClass("et_pb_with_border")&&(carousel_items_height=$the_carousel_items.outerHeight()),$carousel_items.css("height",carousel_items_height+"px")}function set_carousel_columns($the_carousel){var columns,$carousel_parent=$the_carousel.parents(".et_pb_column");$carousel_items.width(),$the_carousel_items.length;if($carousel_parent.hasClass("et_pb_column_4_4")||$carousel_parent.hasClass("et_pb_column_3_4")||$carousel_parent.hasClass("et_pb_column_2_3")?columns=$et_window.width()<768?3:4:$carousel_parent.hasClass("et_pb_column_1_2")||$carousel_parent.hasClass("et_pb_column_3_8")||$carousel_parent.hasClass("et_pb_column_1_3")?columns=3:$carousel_parent.hasClass("et_pb_column_1_4")&&(columns=$et_window.width()>480&&$et_window.width()<980?3:2),columns!==$carousel_items.data("portfolio-columns")&&!$the_carousel.data("columns_setting_up")){$the_carousel.data("columns_setting_up",!0),$carousel_items.removeClass("columns-"+$carousel_items.data("portfolio-columns")),$carousel_items.addClass("columns-"+columns),$carousel_items.data("portfolio-columns",columns),$carousel_items.find(".et-carousel-group").length&&($the_carousel_items.appendTo($carousel_items),$carousel_items.find(".et-carousel-group").remove());var the_carousel_items=$carousel_items.data("items"),$carousel_group=$('"),set_carousel_columns($et_carousel),set_carousel_height($et_carousel),$et_carousel_next=$et_carousel.find(".et-pb-arrow-next"),$et_carousel_prev=$et_carousel.find(".et-pb-arrow-prev"),$et_carousel.on("click",".et-pb-arrow-next",function(){return!$et_carousel.et_animation_running&&($et_carousel.et_carousel_move_to("next"),!1)}),$et_carousel.on("click",".et-pb-arrow-prev",function(){return!$et_carousel.et_animation_running&&($et_carousel.et_carousel_move_to("previous"),!1)}),$et_carousel.on("swipeleft",function(){$et_carousel.et_carousel_move_to("next")}),$et_carousel.on("swiperight",function(){$et_carousel.et_carousel_move_to("previous")}),$et_carousel.et_carousel_move_to=function(direction){var $active_carousel_group=$carousel_items.find(".et-carousel-group.active"),items=$carousel_items.data("items"),columns=$carousel_items.data("portfolio-columns");$et_carousel.et_animation_running=!0;left=0;$active_carousel_group.children().each(function(){$(this).css({position:"absolute",left:left}),left+=$(this).outerWidth(!0)}),$("body").addClass("et-pb-is-sliding-carousel");var carousel_group_item_size=$active_carousel_group.find(".et_pb_carousel_item").size(),carousel_group_item_progress=0;if("next"==direction){var $next_carousel_group,current_position=1,next_position=1,next_items_start=active_items_end=(active_items_start=items.indexOf($active_carousel_group.children().first()[0]))+columns,next_items_end=next_items_start+columns;for(($next_carousel_group=$('